Fix stack stupidity with generators

This commit is contained in:
K. Lange 2021-03-06 17:20:02 +09:00
parent 8dddcfa2e0
commit 0c08398e4a
2 changed files with 3 additions and 3 deletions

View File

@ -1599,7 +1599,7 @@ static void yieldStatement() {
} else {
expression();
}
emitByte(OP_YIELD);
emitBytes(OP_YIELD, OP_POP);
}
static void tryStatement() {
@ -2314,7 +2314,7 @@ static void generatorInner(KrkScanner scannerBefore, Parser parserBefore) {
krk_rewindScanner(scannerBefore);
parser = parserBefore;
expression();
emitByte(OP_YIELD);
emitBytes(OP_YIELD, OP_POP);
krk_rewindScanner(scannerAfter);
parser = parserAfter;
}

View File

@ -101,7 +101,7 @@ KRK_METHOD(generator,__call__,{
size_t newArgs = stackAfter - stackBefore;
self->args = realloc(self->args, sizeof(KrkValue) * (self->argCount + newArgs));
self->argCount += newArgs;
} else if (stackAfter <= stackBefore) {
} else if (stackAfter < stackBefore) {
_set_generator_done(self);
return OBJECT_VAL(self);
}