mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-20 01:04:08 +10:00
Fixed stack overflow caused by expression statements
This is a longstanding bug, so I'm glad its fixed, even if its only a bandaid. This does break some tests, but I'm too tired and these tests are out of date.
This commit is contained in:
@@ -891,6 +891,11 @@ static void makePrintStmt(Toy_Bucket** bucketHandle, Toy_Parser* parser, Toy_Ast
|
||||
|
||||
static void makeExprStmt(Toy_Bucket** bucketHandle, Toy_Parser* parser, Toy_Ast** rootHandle) {
|
||||
makeExpr(bucketHandle, parser, rootHandle);
|
||||
//BUGFIX: don't leave anything on the stack after a unary statement
|
||||
if ((*rootHandle)->type == TOY_AST_VALUE || (*rootHandle)->type == TOY_AST_UNARY || (*rootHandle)->type == TOY_AST_COMPARE || (*rootHandle)->type == TOY_AST_GROUP || (*rootHandle)->type == TOY_AST_COMPOUND || (*rootHandle)->type == TOY_AST_AGGREGATE) {
|
||||
Toy_private_emitAstStackPop(bucketHandle, rootHandle);
|
||||
}
|
||||
|
||||
consume(parser, TOY_TOKEN_OPERATOR_SEMICOLON, "Expected ';' at the end of expression statement");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user