chore: test case for empty logic expression

This commit is contained in:
Brett Broadhurst 2026-03-26 08:37:11 -06:00
parent 8fa228a9c2
commit 7afc6719d9
Failed to generate hash of commit
3 changed files with 16 additions and 4 deletions

View file

@ -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 { 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? if (node.data.bin.lhs) |n| {
const expr_node = node.data.bin.lhs.?; return expr(gi, scope, n);
return expr(gi, scope, expr_node); }
return .none;
} }
fn inlineLogicExpr(gi: *GenIr, scope: *Scope, node: *const Ast.Node) InnerError!Ir.Inst.Ref { fn inlineLogicExpr(gi: *GenIr, scope: *Scope, node: *const Ast.Node) InnerError!Ir.Inst.Ref {

View file

@ -46,6 +46,18 @@ test "parser: expression statements" {
); );
} }
test "parser: empty expression" {
try testEqual(
\\~
,
\\File "<STDIN>"
\\`--BlockStmt <line:1, line:1>
\\ `--ExprStmt <line:1, col:2:2>
\\
,
);
}
test "parser: temporary variables" { test "parser: temporary variables" {
try testEqual( try testEqual(
\\~ temp a = 1 + 2 + 3 \\~ temp a = 1 + 2 + 3

View file

@ -1 +0,0 @@
~