Skip to content

Commit

Permalink
A proc call can use an implicit block. Fixes #3202.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Apr 8, 2016
1 parent b8c365d commit a31755a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
26 changes: 23 additions & 3 deletions core/kernel.rb
Expand Up @@ -725,9 +725,29 @@ def private_singleton_methods
end
private :private_singleton_methods

def proc(&prc)
raise ArgumentError, "block required" unless prc
return prc
def proc
env = nil

Rubinius.asm do
push_block
# assign a pushed block to the above local variable "env"
set_local 0
end

unless env
# Support for ancient pre-block-pass style:
# def something
# proc
# end
# something { a_block } => Proc instance
env = Rubinius::BlockEnvironment.of_sender

unless env
raise ArgumentError, "tried to create a Proc object without a block"
end
end

Proc.new(&env)
end
module_function :proc

Expand Down
1 change: 0 additions & 1 deletion spec/tags/ruby/core/kernel/proc_tags.txt

This file was deleted.

0 comments on commit a31755a

Please sign in to comment.