summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-16 21:13:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-16 21:13:10 +0000
commit0884d0b944de777d22b963dda47294d939c9fd90 (patch)
tree1c461fb938315f690eae1a3d6f5eb9d88ab63a60
parent85ba516877f26444bf9382f19bdb5d94527de945 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--proc.c1
-rw-r--r--test/ruby/test_proc.rb7
3 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b7ca5936807..ec2e4fa219b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Nov 17 06:13:06 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* vm_eval.c (rb_current_receiver): new function to return the
diff --git a/proc.c b/proc.c
index 475259cca90..ecb9a9f4e7b 100644
--- a/proc.c
+++ b/proc.c
@@ -2452,6 +2452,7 @@ proc_binding(VALUE self)
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);
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index f760cce3eef..728e2b79878 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -205,6 +205,13 @@ class TestProc < Test::Unit::TestCase
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