From 7afc6719d9ae0922edad4386c696d05d4664d172 Mon Sep 17 00:00:00 2001 From: Brett Broadhurst Date: Thu, 26 Mar 2026 08:37:11 -0600 Subject: [PATCH] chore: test case for empty logic expression --- src/AstGen.zig | 7 ++++--- src/parser_tests.zig | 12 ++++++++++++ testing/regression/syntax/empty-logic.ink | 1 - 3 files changed, 16 insertions(+), 4 deletions(-) delete mode 100644 testing/regression/syntax/empty-logic.ink diff --git a/src/AstGen.zig b/src/AstGen.zig index 07942ee..82e81f0 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -757,9 +757,10 @@ fn expr(gi: *GenIr, scope: *Scope, optional_expr: ?*const Ast.Node) InnerError!I } fn exprStmt(gi: *GenIr, scope: *Scope, node: *const Ast.Node) InnerError!Ir.Inst.Ref { - // TODO: Maybe we should introduce a unary node type to avoid optional checks? - const expr_node = node.data.bin.lhs.?; - return expr(gi, scope, expr_node); + if (node.data.bin.lhs) |n| { + return expr(gi, scope, n); + } + return .none; } fn inlineLogicExpr(gi: *GenIr, scope: *Scope, node: *const Ast.Node) InnerError!Ir.Inst.Ref { diff --git a/src/parser_tests.zig b/src/parser_tests.zig index d9d56a1..9822b0c 100644 --- a/src/parser_tests.zig +++ b/src/parser_tests.zig @@ -46,6 +46,18 @@ test "parser: expression statements" { ); } +test "parser: empty expression" { + try testEqual( + \\~ + , + \\File "" + \\`--BlockStmt + \\ `--ExprStmt + \\ + , + ); +} + test "parser: temporary variables" { try testEqual( \\~ temp a = 1 + 2 + 3 diff --git a/testing/regression/syntax/empty-logic.ink b/testing/regression/syntax/empty-logic.ink deleted file mode 100644 index 54bcf30..0000000 --- a/testing/regression/syntax/empty-logic.ink +++ /dev/null @@ -1 +0,0 @@ -~