Commit 06a67df9 authored by ksss's avatar ksss

OP_ENTER clean block object in register

parent c071ad13
...@@ -1307,6 +1307,7 @@ RETRY_TRY_BLOCK: ...@@ -1307,6 +1307,7 @@ RETRY_TRY_BLOCK:
mrb->c->ci->argc = len; mrb->c->ci->argc = len;
if (argc < len) { if (argc < len) {
regs[len+1] = *blk; /* move block */ regs[len+1] = *blk; /* move block */
SET_NIL_VALUE(regs[argc+1]);
if (argv0 != argv) { if (argv0 != argv) {
value_move(&regs[1], argv, argc-m2); /* m1 + o */ value_move(&regs[1], argv, argc-m2); /* m1 + o */
} }
......
...@@ -55,6 +55,23 @@ assert('Proc#call', '15.2.17.4.3') do ...@@ -55,6 +55,23 @@ assert('Proc#call', '15.2.17.4.3') do
assert_equal 5, a2 assert_equal 5, a2
end end
assert('Proc#call proc args pos block') do
pr = proc {|a,b,&c|
[a, b, c.class, c&&c.call(:x)]
}
assert_equal [nil, nil, Proc, :proc], (pr.call(){ :proc })
assert_equal [1, nil, Proc, :proc], (pr.call(1){ :proc })
assert_equal [1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
assert_equal [1, 2, Proc, :proc], (pr.call(1, 2, 3){ :proc })
assert_equal [1, 2, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
assert_equal [nil, nil, Proc, :x], (pr.call(){|x| x})
assert_equal [1, nil, Proc, :x], (pr.call(1){|x| x})
assert_equal [1, 2, Proc, :x], (pr.call(1, 2){|x| x})
assert_equal [1, 2, Proc, :x], (pr.call(1, 2, 3){|x| x})
assert_equal [1, 2, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
end
assert('Proc#return_does_not_break_self') do assert('Proc#return_does_not_break_self') do
class TestClass class TestClass
attr_accessor :block attr_accessor :block
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment