| author | |
| committer | |
| log | bbc2e7a74da98cfcf7bd24f1904cc77a203002f8 |
| tree | aa4d46b3588d89ba5c0be5b6d23e21c2a39dedd1 |
| parent | 84ac2e8714735ceeefad840e41961f6407e0c619 |
2 files changed, 10 insertions(+), 5 deletions(-)
lib/std/zig/Parse.zig+9-5| ... | @@ -919,11 +919,15 @@ fn expectStatement(p: *Parse, allow_defer_var: bool) Error!Node.Index { | ... | @@ -919,11 +919,15 @@ fn expectStatement(p: *Parse, allow_defer_var: bool) Error!Node.Index { |
| 919 | } else { | 919 | } else { |
| 920 | const assign = try p.expectAssignExpr(); | 920 | const assign = try p.expectAssignExpr(); |
| 921 | try p.expectSemicolon(.expected_semi_after_stmt, true); | 921 | try p.expectSemicolon(.expected_semi_after_stmt, true); |
| 922 | return p.addNode(.{ | 922 | if (p.nodeTag(assign) != .assign_destructure) { |
| 923 | .tag = .@"comptime", | 923 | return p.addNode(.{ |
| 924 | .main_token = comptime_token, | 924 | .tag = .@"comptime", |
| 925 | .data = .{ .node = assign }, | 925 | .main_token = comptime_token, |
| 926 | }); | 926 | .data = .{ .node = assign }, |
| 927 | }); | ||
| 928 | } else { | ||
| 929 | return assign; | ||
| 930 | } | ||
| 927 | } | 931 | } |
| 928 | } | 932 | } |
| 929 | 933 |
lib/std/zig/parser_test.zig+1| ... | @@ -2886,6 +2886,7 @@ test "zig fmt: destructure" { | ... | @@ -2886,6 +2886,7 @@ test "zig fmt: destructure" { |
| 2886 | \\ comptime w, var y = .{ 3, 4 }; | 2886 | \\ comptime w, var y = .{ 3, 4 }; |
| 2887 | \\ comptime var z, x = .{ 5, 6 }; | 2887 | \\ comptime var z, x = .{ 5, 6 }; |
| 2888 | \\ comptime y, z = .{ 7, 8 }; | 2888 | \\ comptime y, z = .{ 7, 8 }; |
| 2889 | \\ if (false) unreachable else comptime a, b = .{ 9, 10 }; | ||
| 2889 | \\} | 2890 | \\} |
| 2890 | \\ | 2891 | \\ |
| 2891 | ); | 2892 | ); |