Updated parser unit test, fixed a missing stack pop for binary exprStmt

This commit is contained in:
2026-04-22 11:40:53 +10:00
parent 2c92f829e1
commit 47c5d49069
2 changed files with 230 additions and 180 deletions
+10 -1
View File
@@ -892,7 +892,16 @@ 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) {
if (
(*rootHandle)->type == TOY_AST_VALUE ||
(*rootHandle)->type == TOY_AST_UNARY ||
(*rootHandle)->type == TOY_AST_BINARY ||
(*rootHandle)->type == TOY_AST_BINARY_SHORT_CIRCUIT ||
(*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);
}