diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-01 00:43:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-01 00:43:00 +0000 |
commit | 7587bb9848128278d8fdd580b234e5d9a4b808bd (patch) | |
tree | 204294bf8262b0bc3c9bc97f32302643df6e6a34 | |
parent | d8e2be0f7ee87525348908ad0ec269452003c37f (diff) | |
download | ruby-7587bb9848128278d8fdd580b234e5d9a4b808bd.tar.gz |
compile.c: ensure after toplevel return
* compile.c (iseq_compile_each0): toplevel returns should fire
ensures. [ruby-core:82492] [Bug #13844]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | compile.c | 4 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 2 |
2 files changed, 3 insertions, 3 deletions
@@ -5771,7 +5771,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp const rb_iseq_t *parent_iseq = is->body->parent_iseq; enum iseq_type parent_type; - if (type == ISEQ_TYPE_TOP || type == ISEQ_TYPE_MAIN) { + if (type == ISEQ_TYPE_TOP) { LABEL *splabel = NEW_LABEL(line); ADD_LABEL(ret, splabel); ADD_ADJUST(ret, line, 0); @@ -5779,7 +5779,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp ADD_INSN(ret, line, leave); ADD_ADJUST_RESTORE(ret, splabel); } - else if ((type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE) && + else if ((type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE || type == ISEQ_TYPE_MAIN) && parent_iseq && ((parent_type = parent_iseq->body->type) == ISEQ_TYPE_TOP || parent_type == ISEQ_TYPE_MAIN)) { diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index eaebbcf1bf..57cc5b9611 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -986,7 +986,7 @@ eom begin; return; raise begin return; rescue SystemExit; exit false; end - begin return; ensure exit false; end + begin return; ensure puts "ensured"; end #=> ensured begin ensure return; end begin raise; ensure; return; end begin raise; rescue; return; end |