Skip to content

Commit d4b5163

Browse files
committed
Another attempt to fix infinite loop in foreach
Without this commit, this causes a busy loop: >> foreach [a:] [1 2 3][ print mold a] Fix CC#1751
1 parent 1c04463 commit d4b5163

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/core/n-loop.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@
400400
else SET_NONE(vars);
401401
}
402402

403-
// var spec is WORD:
403+
// var spec is SET_WORD:
404404
else if (IS_SET_WORD(words)) {
405405
if (ANY_OBJECT(value) || IS_MAP(value)) {
406406
*vars = *value;
@@ -413,6 +413,7 @@
413413
}
414414
else Trap_Arg(words);
415415
}
416+
if (index == rindex) index++; //the word block has only set-words: foreach [a:] [1 2 3][]
416417

417418
ds = Do_Blk(body, 0);
418419

0 commit comments

Comments
 (0)