mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
std.zig.parser now allows assignment expr in switch cases.
This makes `std/os/index.zig` parse related: #909
This commit is contained in:
parent
4b0556ebd4
commit
841ac0f4e1
@ -2036,7 +2036,7 @@ pub const Parser = struct {
|
||||
);
|
||||
try list_state.list.append(node);
|
||||
stack.append(State { .SwitchCaseCommaOrEnd = list_state }) catch unreachable;
|
||||
try stack.append(State { .Expression = DestPtr{ .Field = &node.expr } });
|
||||
try stack.append(State { .AssignmentExpressionBegin = DestPtr{ .Field = &node.expr } });
|
||||
try stack.append(State { .PointerPayload = &node.payload });
|
||||
|
||||
const maybe_else = self.getNextToken();
|
||||
@ -4817,6 +4817,7 @@ test "zig fmt: switch" {
|
||||
\\ const res = switch (0) {
|
||||
\\ 0 => 0,
|
||||
\\ 1 => 2,
|
||||
\\ 1 => a = 4,
|
||||
\\ else => 4
|
||||
\\ };
|
||||
\\
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user