mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix redo keyword
Add `OP_NOP` to distinguish `retry` and jump targets while maintaining instruction compatibility. Ideally, it might be preferable to separate them into `OP_REDO`. fixed #6439
This commit is contained in:
@@ -1323,6 +1323,7 @@ for_body(codegen_scope *s, node *tree)
|
||||
/* construct loop */
|
||||
lp = loop_push(s, LOOP_FOR);
|
||||
lp->pc1 = new_label(s);
|
||||
genop_0(s, OP_NOP); /* for redo */
|
||||
|
||||
/* loop body */
|
||||
codegen(s, tree->cdr->cdr->car, VAL);
|
||||
@@ -2589,6 +2590,7 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
pos = genjmp2_0(s, OP_JMPIF, cursp(), NOVAL);
|
||||
}
|
||||
lp->pc1 = new_label(s);
|
||||
genop_0(s, OP_NOP); /* for redo */
|
||||
codegen(s, tree->cdr, NOVAL);
|
||||
genjmp(s, OP_JMP, lp->pc0);
|
||||
dispatch(s, pos);
|
||||
|
||||
Reference in New Issue
Block a user