[前][次][番号順一覧][スレッド一覧]

ruby-changes:61992

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:46 +0900 (JST)
Subject: [ruby-changes:61992] aa2cb7f722 (master): compile_redo: do not goto into a branch

https://git.ruby-lang.org/ruby.git/commit/?id=aa2cb7f722

From aa2cb7f7228baa5a5fffab733f3960546c852aa5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Fri, 12 Jun 2020 13:39:10 +0900
Subject: 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.

diff --git a/compile.c b/compile.c
index a17323e..8982ce4 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L6708
 	    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 https://github.com/ruby/ruby/blob/trunk/compile.c#L6738
 		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;
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]