diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-02-24 19:19:14 -0800 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-02-24 19:19:14 -0800 |
| commit | 815177afc7f5cef8e447bb9f2878d49fd0bd615c (patch) | |
| tree | 0ea8dea54e340a94fa0b34d48d3eafc0579592d0 | |
| parent | bbd50cca2f78c642517beaeccd26400798b1ec46 (diff) | |
| parent | efa18038de038c366c6ee54f47670c80ec068aad (diff) | |
| download | mruby-815177afc7f5cef8e447bb9f2878d49fd0bd615c.tar.gz mruby-815177afc7f5cef8e447bb9f2878d49fd0bd615c.zip | |
Merge pull request #883 from masamitsu-murase/modify_node_rescue_handling
Adjust stack position of NODE_RESCUE.
| -rw-r--r-- | src/codegen.c | 4 | ||||
| -rw-r--r-- | test/t/exception.rb | 28 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/codegen.c b/src/codegen.c index 86d61fecf..d3239259b 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -1083,6 +1083,7 @@ codegen(codegen_scope *s, node *tree, int val) } if (n3->cdr->cdr->car) { codegen(s, n3->cdr->cdr->car, val); + if (val) pop(); } tmp = new_label(s); genop(s, MKOP_sBx(OP_JMP, exend)); @@ -1102,6 +1103,9 @@ codegen(codegen_scope *s, node *tree, int val) if (tree->car) { codegen(s, tree->car, val); } + else if (val) { + push(); + } dispatch_linked(s, exend); loop_pop(s, NOVAL); } diff --git a/test/t/exception.rb b/test/t/exception.rb index a2e6acc07..663c8f337 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -287,6 +287,34 @@ assert('Exception 16') do end end +assert('Exception 17') do + begin + raise "a" # StandardError + rescue ArgumentError + 1 + rescue StandardError + 2 + else + 3 + ensure + 4 + end == 2 +end + +assert('Exception 18') do + begin + 0 + rescue ArgumentError + 1 + rescue StandardError + 2 + else + 3 + ensure + 4 + end == 3 +end + assert('Exception#inspect without message') do Exception.new.inspect end |
