for ...;... should not accept multiple expressions for condition

This commit is contained in:
K. Lange 2021-02-22 14:19:28 +09:00
parent 6fee62f341
commit f74c6c77b1

View File

@ -1488,9 +1488,7 @@ static void forStatement() {
loopStart = currentChunk()->count;
beginScope();
do {
expression(); /* condition */
} while (match(TOKEN_COMMA));
expression(); /* condition */
endScope();
exitJump = emitJump(OP_JUMP_IF_FALSE);
emitByte(OP_POP);
@ -1501,10 +1499,9 @@ static void forStatement() {
int incrementStart = currentChunk()->count;
beginScope();
do {
expression();
expressionStatement();
} while (match(TOKEN_COMMA));
endScope();
emitByte(OP_POP);
emitLoop(loopStart);
loopStart = incrementStart;