summaryrefslogtreecommitdiff
path: root/prism_compile.c
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2024-09-18 16:54:56 -0700
committer<[email protected]>2024-09-18 16:54:56 -0700
commit268c72377b06b7d84a0998ca241340d0f58768f6 ()
tree517bcd762780681b88a2cea5d6318b7a244a6144 /prism_compile.c
parent984a791d58ec4350d62714a2d063c1bb54707bb6 (diff)
Raise a compile error for break/next/redo inside eval in cases where it is optimized away
In cases where break/next/redo are not valid syntax, they should raise a SyntaxError even if inside a conditional block that is optimized away. Fixes [Bug #20597] Co-authored-by: Kevin Newton <[email protected]>
Notes: Merged: https://.com/ruby/ruby/pull/11099 Merged-By: jeremyevans <[email protected]>
-rw-r--r--prism_compile.c6
1 files changed, 3 insertions, 3 deletions
@@ -7275,7 +7275,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
throw_flag = 0;
}
else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
- COMPILE_ERROR(iseq, location.line, "Can't escape from eval with break");
return;
}
else {
@@ -9047,7 +9047,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
break;
}
else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
- COMPILE_ERROR(iseq, location.line, "Can't escape from eval with next");
return;
}
@@ -9300,7 +9300,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
break;
}
else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
- COMPILE_ERROR(iseq, location.line, "Can't escape from eval with redo");
return;
}