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

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
This commit is contained in:
nobu 2014-11-16 21:13:10 +00:00
parent 85ba516877
commit 0884d0b944
3 changed files with 13 additions and 0 deletions

View file

@ -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

1
proc.c
View file

@ -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);

View file

@ -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