diff options
| -rw-r--r-- | src/codegen.c | 3 | ||||
| -rw-r--r-- | test/t/exception.rb | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/codegen.c b/src/codegen.c index 2482209cc..1f087b2cd 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -267,6 +267,8 @@ genop_peep(codegen_scope *s, mrb_code i, int val) break; case OP_RETURN: switch (c0) { + case OP_RETURN: + return; case OP_MOVE: s->iseq[s->pc-1] = MKOP_AB(OP_RETURN, GETARG_B(i0), OP_R_NORMAL); return; @@ -972,6 +974,7 @@ codegen(codegen_scope *s, node *tree, int val) lp->pc1 = onerr; if (tree->car) { codegen(s, tree->car, val); + if (val) pop(); } lp->type = LOOP_RESCUE; noexc = new_label(s); diff --git a/test/t/exception.rb b/test/t/exception.rb index 76c165e95..aa707c1b1 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -30,7 +30,7 @@ end assert('Exception#to_s', '15.2.22.5.3') do e = Exception.exception('a') - + e.to_s == 'a' end @@ -269,6 +269,24 @@ assert('Exception 14') do a == :ok end +assert('Exception 15') do + a = begin + :ok + rescue + :ng + end + a == :ok +end + +assert('Exception 16') do + begin + raise "foo" + false + rescue => e + e.message == "foo" + end +end + assert('Exception#inspect without message') do Exception.new.inspect end |
