mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Ast: fix comptime wrapper for destructure
This commit is contained in:
parent
c9acfe4c2b
commit
4b73d5e029
2 changed files with 10 additions and 5 deletions
|
|
@ -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);
|
||||
return p.addNode(.{
|
||||
.tag = .@"comptime",
|
||||
.main_token = comptime_token,
|
||||
.data = .{ .node = assign },
|
||||
});
|
||||
if (p.nodeTag(assign) != .assign_destructure) {
|
||||
return p.addNode(.{
|
||||
.tag = .@"comptime",
|
||||
.main_token = comptime_token,
|
||||
.data = .{ .node = assign },
|
||||
});
|
||||
} else {
|
||||
return assign;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue