Skip to content

Commit 841ac0f

Browse files
committed
std.zig.parser now allows assignment expr in switch cases.
This makes `std/os/index.zig` parse related: #909
1 parent 4b0556e commit 841ac0f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

std/zig/parser.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ pub const Parser = struct {
20362036
);
20372037
try list_state.list.append(node);
20382038
stack.append(State { .SwitchCaseCommaOrEnd = list_state }) catch unreachable;
2039-
try stack.append(State { .Expression = DestPtr{ .Field = &node.expr } });
2039+
try stack.append(State { .AssignmentExpressionBegin = DestPtr{ .Field = &node.expr } });
20402040
try stack.append(State { .PointerPayload = &node.payload });
20412041

20422042
const maybe_else = self.getNextToken();
@@ -4817,6 +4817,7 @@ test "zig fmt: switch" {
48174817
\\ const res = switch (0) {
48184818
\\ 0 => 0,
48194819
\\ 1 => 2,
4820+
\\ 1 => a = 4,
48204821
\\ else => 4
48214822
\\ };
48224823
\\

0 commit comments

Comments
 (0)