summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-12 13:39:10 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commitaa2cb7f7228baa5a5fffab733f3960546c852aa5 (patch)
tree6c240d60d514621bab6719c961ad2c771335fe9c
parentcf29de7e6e92497c31ef08b567fcfe1b72bfaff7 (diff)
compile_redo: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3247
-rw-r--r--compile.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/compile.c b/compile.c
index a17323e8f8..8982ce473a 100644
--- a/compile.c
+++ b/compile.c
@@ -6708,12 +6708,7 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
ADD_INSN(ret, line, putnil);
}
}
- else if (iseq->body->type == ISEQ_TYPE_EVAL) {
- redo_in_eval:
- COMPILE_ERROR(ERROR_ARGS "Can't escape from eval with redo");
- return COMPILE_NG;
- }
- else if (ISEQ_COMPILE_DATA(iseq)->start_label) {
+ else if (iseq->body->type == ISEQ_TYPE_EVAL && ISEQ_COMPILE_DATA(iseq)->start_label) {
LABEL *splabel = NEW_LABEL(0);
debugs("redo in block");
@@ -6743,7 +6738,8 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
break;
}
else if (ip->body->type == ISEQ_TYPE_EVAL) {
- goto redo_in_eval;
+ COMPILE_ERROR(ERROR_ARGS "Can't escape from eval with redo");
+ return COMPILE_NG;
}
ip = ip->body->parent_iseq;