Ast: fix comptime wrapper for destructure

This commit is contained in:
Kendall Condon 2025-07-28 14:03:20 -04:00
parent c9acfe4c2b
commit 4b73d5e029
2 changed files with 10 additions and 5 deletions

View file

@ -919,11 +919,15 @@ fn expectStatement(p: *Parse, allow_defer_var: bool) Error!Node.Index {
} else {
const assign = try p.expectAssignExpr();
try p.expectSemicolon(.expected_semi_after_stmt, true);
if (p.nodeTag(assign) != .assign_destructure) {
return p.addNode(.{
.tag = .@"comptime",
.main_token = comptime_token,
.data = .{ .node = assign },
});
} else {
return assign;
}
}
}

View file

@ -2949,6 +2949,7 @@ test "zig fmt: destructure" {
\\ comptime w, var y = .{ 3, 4 };
\\ comptime var z, x = .{ 5, 6 };
\\ comptime y, z = .{ 7, 8 };
\\ if (false) unreachable else comptime a, b = .{ 9, 10 };
\\}
\\
);