diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-27 14:09:08 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-27 14:09:08 +0000 |
commit | 5cfda37971da176ceba204d57acb5821c293d555 (patch) | |
tree | 6d19af6504aa9e50f72eff9523fe8523dad10e70 /compile.c | |
parent | 1474acff3c70c3c81cb1b059a8e6cc77a0fc4b70 (diff) | |
download | ruby-5cfda37971da176ceba204d57acb5821c293d555.tar.gz |
fix return in toplevel ensure
* compile.c (iseq_compile_each0): adjust stack after return in
toplevel ensure, when the value is used.
[ruby-core:81777] [Bug #13682]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -4824,8 +4824,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp CHECK(COMPILE_POPPED(ensr, "ensure ensr", node->nd_ensr)); last = ensr->last; last_leave = last && IS_INSN(last) && IS_INSN_ID(last, leave); - if (!popped && last_leave) - popped = 1; er.begin = lstart; er.end = lend; @@ -4833,13 +4831,16 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp push_ensure_entry(iseq, &enl, &er, node->nd_ensr); ADD_LABEL(ret, lstart); - CHECK(COMPILE_(ret, "ensure head", node->nd_head, popped)); + CHECK(COMPILE_(ret, "ensure head", node->nd_head, (popped | last_leave))); ADD_LABEL(ret, lend); if (ensr->anchor.next == NULL) { ADD_INSN(ret, line, nop); } else { ADD_SEQ(ret, ensr); + if (!popped && last_leave) { + ADD_INSN(ret, line, putnil); + } } ADD_LABEL(ret, lcont); if (last_leave) ADD_INSN(ret, line, pop); |