chore: test case for empty logic expression
This commit is contained in:
parent
8fa228a9c2
commit
7afc6719d9
3 changed files with 16 additions and 4 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
~
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue