[前][次][番号順一覧][スレッド一覧]

ruby-changes:36385

From: nobu <ko1@a...>
Date: Mon, 17 Nov 2014 06:13:21 +0900 (JST)
Subject: [ruby-changes:36385] nobu:r48466 (trunk): proc.c: fix method proc binding location

nobu	2014-11-17 06:13:10 +0900 (Mon, 17 Nov 2014)

  New Revision: 48466

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48466

  Log:
    proc.c: fix method proc binding location
    
    * proc.c (proc_binding): use the original iseq on a binding from
      proc from method object to get the location.

  Modified files:
    trunk/ChangeLog
    trunk/proc.c
    trunk/test/ruby/test_proc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48465)
+++ ChangeLog	(revision 48466)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Nov 17 06:13:06 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* proc.c (proc_binding): use the original iseq on a binding from
+	  proc from method object to get the location.
+
 Sun Nov 16 19:38:10 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm_eval.c (rb_current_receiver): new function to return the
Index: proc.c
===================================================================
--- proc.c	(revision 48465)
+++ proc.c	(revision 48466)
@@ -2452,6 +2452,7 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2452
 	if (!IS_METHOD_PROC_NODE((NODE *)iseq)) {
 	    rb_raise(rb_eArgError, "Can't create Binding from C level Proc");
 	}
+	iseq = rb_method_get_iseq(RNODE(iseq)->u2.value);
     }
 
     bindval = rb_binding_alloc(rb_cBinding);
Index: test/ruby/test_proc.rb
===================================================================
--- test/ruby/test_proc.rb	(revision 48465)
+++ test/ruby/test_proc.rb	(revision 48466)
@@ -205,6 +205,13 @@ class TestProc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_proc.rb#L205
     assert_instance_of(Binding, b, '[ruby-core:25589]')
     bug10432 = '[ruby-core:65919] [Bug #10432]'
     assert_same(self, b.receiver, bug10432)
+    assert_not_send [b, :local_variable_defined?, :value]
+    assert_raise(NameError) {
+      b.local_variable_get(:value)
+    }
+    assert_equal 42, b.local_variable_set(:value, 42)
+    assert_send [b, :local_variable_defined?, :value]
+    assert_equal 42, b.local_variable_get(:value)
   end
 
   def test_block_given_method

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]