ruby-changes:5934
From: ko1 <ko1@a...>
Date: Fri, 20 Jun 2008 00:43:42 +0900 (JST)
Subject: [ruby-changes:5934] Ruby:r17442 (trunk): * proc.c (proc_new): fix to return Proc object if block is already
ko1 2008-06-20 00:43:25 +0900 (Fri, 20 Jun 2008) New Revision: 17442 Modified files: trunk/ChangeLog trunk/bootstraptest/test_proc.rb trunk/proc.c Log: * 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. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17442&r2=17441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_proc.rb?r1=17442&r2=17441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/proc.c?r1=17442&r2=17441&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 17441) +++ ChangeLog (revision 17442) @@ -1,3 +1,10 @@ +Fri Jun 20 00:40:08 2008 Koichi Sasada <ko1@a...> + + * 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@a...> * thread_win32.c (native_sleep): fix to decrement sleeper count. Index: bootstraptest/test_proc.rb =================================================================== --- bootstraptest/test_proc.rb (revision 17441) +++ bootstraptest/test_proc.rb (revision 17442) @@ -378,3 +378,20 @@ 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]' Index: proc.c =================================================================== --- proc.c (revision 17441) +++ proc.c (revision 17442) @@ -358,6 +358,10 @@ 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/