zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit bbc2e7a74da98cfcf7bd24f1904cc77a203002f8 (tree)
parent 84ac2e8714735ceeefad840e41961f6407e0c619
Author: Kendall Condon <goon.pri.low@gmail.com>
Date:   Mon, 28 Jul 2025 14:03:20 -0400

Ast: fix comptime wrapper for destructure

Diffstat:
Mlib/std/zig/Parse.zig | 14+++++++++-----
Mlib/std/zig/parser_test.zig | 1+
2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/std/zig/Parse.zig b/lib/std/zig/Parse.zig @@ -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; + } } } diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig @@ -2886,6 +2886,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 }; \\} \\ );