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 @@ -~