mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
proc.c: fail symbol proc binding
* proc.c (proc_binding): proc from symbol can not make a binding. [ruby-core:74100] [Bug #12137] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
50591a768d
commit
6c7fd3b5cf
3 changed files with 16 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Mar 16 20:03:35 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* proc.c (proc_binding): proc from symbol can not make a binding.
|
||||||
|
[ruby-core:74100] [Bug #12137]
|
||||||
|
|
||||||
Wed Mar 16 18:42:45 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
Wed Mar 16 18:42:45 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
* test/ruby/enc/test_case_mapping.rb: Fixed and activated a test for Cherokee.
|
* test/ruby/enc/test_case_mapping.rb: Fixed and activated a test for Cherokee.
|
||||||
|
|
2
proc.c
2
proc.c
|
@ -2658,6 +2658,7 @@ proc_binding(VALUE self)
|
||||||
GetProcPtr(self, proc);
|
GetProcPtr(self, proc);
|
||||||
envval = rb_vm_proc_envval(proc);
|
envval = rb_vm_proc_envval(proc);
|
||||||
iseq = proc->block.iseq;
|
iseq = proc->block.iseq;
|
||||||
|
if (SYMBOL_P(iseq)) goto error;
|
||||||
if (RUBY_VM_IFUNC_P(iseq)) {
|
if (RUBY_VM_IFUNC_P(iseq)) {
|
||||||
struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq;
|
struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq;
|
||||||
if (IS_METHOD_PROC_IFUNC(ifunc)) {
|
if (IS_METHOD_PROC_IFUNC(ifunc)) {
|
||||||
|
@ -2666,6 +2667,7 @@ proc_binding(VALUE self)
|
||||||
iseq = rb_method_iseq(method);
|
iseq = rb_method_iseq(method);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
error:
|
||||||
rb_raise(rb_eArgError, "Can't create Binding from C level Proc");
|
rb_raise(rb_eArgError, "Can't create Binding from C level Proc");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,15 @@ class TestSymbol < Test::Unit::TestCase
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_to_proc_binding
|
||||||
|
assert_separately([], <<~"end;", timeout: 1) # do
|
||||||
|
bug12137 = '[ruby-core:74100] [Bug #12137]'
|
||||||
|
assert_raise(ArgumentError, bug12137) {
|
||||||
|
:succ.to_proc.binding
|
||||||
|
}
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
|
||||||
def test_call
|
def test_call
|
||||||
o = Object.new
|
o = Object.new
|
||||||
def o.foo(x, y); x + y; end
|
def o.foo(x, y); x + y; end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue