Allow redo from nested LOOP_BEGIN and LOOP_RESCUE

This commit is contained in:
dearblue
2024-12-01 11:34:10 +09:00
parent 01ea2c088d
commit 939659e2db
+8 -5
View File
@@ -3183,11 +3183,14 @@ codegen(codegen_scope *s, node *tree, int val)
break;
case NODE_REDO:
if (!s->loop || s->loop->type == LOOP_BEGIN || s->loop->type == LOOP_RESCUE) {
raise_error(s, "unexpected redo");
}
else {
genjmp(s, OP_JMPUW, s->loop->pc1);
for (const struct loopinfo *lp = s->loop; ; lp = lp->prev) {
if (!lp) {
raise_error(s, "unexpected redo");
}
if (lp->type != LOOP_BEGIN && lp->type != LOOP_RESCUE) {
genjmp(s, OP_JMPUW, lp->pc1);
break;
}
}
if (val) push();
break;