authorgravatar for mpoliwczak34@gmail.comMateusz Poliwczak <mpoliwczak34@gmail.com> 2025-11-07 08:21:57+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-11-10 14:02:37+00:00
logd942f693c5ed6ea8d12b38960af72e44c10efb57
treefe69384dc64c2cea17cc32baff2dc547d14fd8d8
parentce355e0ba5b752e5f737a7ef7ef85d45b3d4f08a

std.zig.AstGen: properly handle grouped_expression

This fixes an endless loop in the compiler.

2 files changed, 10 insertions(+), 1 deletions(-)

lib/std/zig/AstGen.zig+1-1
......@@ -2607,7 +2607,7 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod
26072607 .assign_mul_wrap => try assignOp(gz, scope, statement, .mulwrap),
26082608
26092609 .grouped_expression => {
2610 inner_node = tree.nodeData(statement).node_and_token[0];
2610 inner_node = tree.nodeData(inner_node).node_and_token[0];
26112611 continue;
26122612 },
26132613
test/cases/compile_errors/doubled_grouped_expr_as_stmt.zig created+9
......@@ -0,0 +1,9 @@
1pub export fn entry() void {
2 ((1 + 1)); // makes sure that the doubled grouped_expression does not cause an endless loop in AstGen.
3}
4
5// error
6//
7// :2:9: error: value of type 'comptime_int' ignored
8// :2:9: note: all non-void values must be used
9// :2:9: note: to discard the value, assign it to '_'