Commit 0bce3a36 authored by Keita Obo's avatar Keita Obo

Fixed self value in a block is changed with return value

fix #1504
parent ccadbbeb
......@@ -286,8 +286,7 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
case OP_RANGE:
case OP_AREF:
case OP_GETUPVAR:
s->iseq[s->pc-1] = MKOP_ABC(c0, 0, GETARG_B(i0), GETARG_C(i0));
genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
genop(s, MKOP_AB(OP_RETURN, GETARG_A(i0), OP_R_NORMAL));
return;
case OP_SETIV:
case OP_SETCV:
......
......@@ -54,3 +54,19 @@ assert('Proc#call', '15.2.17.4.3') do
assert_equal 1, a
assert_equal 5, a2
end
assert('Proc#return_does_not_break_self') do
class TestClass
attr_accessor :block
def initialize
end
def register_block
@block = Proc.new { self }
return []
end
end
c = TestClass.new
assert_equal [], c.register_block
assert_equal c, c.block.call
end
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