diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-31 09:33:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-31 09:33:22 +0000 |
commit | 84d931415ee8d8839c7fcc65047a8b1112ab851d (patch) | |
tree | 800eb0692719076327caf7843c2ea4ac1d32a888 /compile.c | |
parent | 6806c16fefa62e420da73ed37ba94690dab18afc (diff) |
compile.c: ensure after return in library toplevel
* compile.c (compile_return): execute ensure clause after toplevel
return even in library toplevel other than the main script.
[ruby-core:83589] [Bug #14061]
test
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 19 |
1 files changed, 5 insertions, 14 deletions
@@ -5111,27 +5111,18 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, enum iseq_type type = iseq->body->type; const rb_iseq_t *parent_iseq = iseq->body->parent_iseq; enum iseq_type parent_type; + const NODE *retval = node->nd_stts; LABEL *splabel = 0; if (type == ISEQ_TYPE_TOP) { - splabel = NEW_LABEL(line); - ADD_LABEL(ret, splabel); - ADD_ADJUST(ret, line, 0); - ADD_INSN(ret, line, putnil); - ADD_INSN(ret, line, leave); - ADD_ADJUST_RESTORE(ret, splabel); - return COMPILE_OK; + retval = 0; + type = ISEQ_TYPE_METHOD; } 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)) { - ADD_INSN(ret, line, putnil); - ADD_INSN1(ret, line, throw, INT2FIX(TAG_RETURN)); - if (popped) { - ADD_INSN(ret, line, pop); - } - return COMPILE_OK; + retval = 0; } if (type == ISEQ_TYPE_METHOD) { @@ -5140,7 +5131,7 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, ADD_ADJUST(ret, line, 0); } - CHECK(COMPILE(ret, "return nd_stts (return val)", node->nd_stts)); + CHECK(COMPILE(ret, "return nd_stts (return val)", retval)); if (type == ISEQ_TYPE_METHOD) { add_ensure_iseq(ret, iseq, 1); |