summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/codegen.c3
-rw-r--r--test/t/proc.rb16
2 files changed, 17 insertions, 2 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 1efc44ba0..7e5a7fa50 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -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:
diff --git a/test/t/proc.rb b/test/t/proc.rb
index 4227772dd..8587a7bc7 100644
--- a/test/t/proc.rb
+++ b/test/t/proc.rb
@@ -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