1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* proc.c (proc_new): fix to return Proc object if block is already

in heap.  [ruby-core:15711]
* bootstraptest/test_proc.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2008-06-19 15:43:25 +00:00
parent af94c81302
commit e7dac48a91
3 changed files with 28 additions and 0 deletions

View file

@ -1,3 +1,10 @@
Fri Jun 20 00:40:08 2008 Koichi Sasada <ko1@atdot.net>
* proc.c (proc_new): fix to return Proc object if block is already
in heap. [ruby-core:15711]
* bootstraptest/test_proc.rb: add a test.
Fri Jun 20 00:18:04 2008 Koichi Sasada <ko1@atdot.net>
* thread_win32.c (native_sleep): fix to decrement sleeper count.

View file

@ -378,3 +378,20 @@ assert_equal 'ok', %q{
m()
}
assert_equal 'ok', %q{
class Foo
def call_it
p = Proc.new
p.call
end
end
def give_it
proc { :ok }
end
f = Foo.new
a_proc = give_it
p :call_it
f.call_it(&give_it())
}, '[ruby-core:15711]'

4
proc.c
View file

@ -358,6 +358,10 @@ proc_new(VALUE klass, int is_lambda)
block = GC_GUARDED_PTR_REF(cfp->lfp[0]);
if (block->proc) {
return block->proc;
}
/* TODO: check more (cfp limit, called via cfunc, etc) */
while (cfp->dfp != block->dfp) {
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);