authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-02-24 12:14:15+01:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-02-24 12:14:15+01:00
log1b8eca030e9dac51361d80428f8276a09f31a8c2
treeb869bdbd5da5ad8b2b7e261b46b80f8d57010865
parentdb4c15be507a55f63b7f19dd4cdc10717f44eb06
signaturelock-open Commit is signed but in an unrecognized format.

zig fmt: fix firstToken() for switch_case


2 files changed, 13 insertions(+), 14 deletions(-)

lib/std/zig/ast.zig+1-1
...@@ -580,7 +580,7 @@ pub const Tree = struct {...@@ -580,7 +580,7 @@ pub const Tree = struct {
580 .switch_case => {580 .switch_case => {
581 const extra = tree.extraData(datas[n].lhs, Node.SubRange);581 const extra = tree.extraData(datas[n].lhs, Node.SubRange);
582 assert(extra.end - extra.start > 0);582 assert(extra.end - extra.start > 0);
583 n = extra.start;583 n = tree.extra_data[extra.start];
584 },584 },
585585
586 .asm_output, .asm_input => {586 .asm_output, .asm_input => {
lib/std/zig/parser_test.zig+12-13
...@@ -4189,19 +4189,18 @@ test "zig fmt: respect extra newline between fn and pub usingnamespace" {...@@ -4189,19 +4189,18 @@ test "zig fmt: respect extra newline between fn and pub usingnamespace" {
4189 );4189 );
4190}4190}
41914191
4192// TODO4192test "zig fmt: respect extra newline between switch items" {
4193//test "zig fmt: respect extra newline between switch items" {4193 try testCanonical(
4194// try testCanonical(4194 \\const a = switch (b) {
4195// \\const a = switch (b) {4195 \\ .c => {},
4196// \\ .c => {},4196 \\
4197// \\4197 \\ .d,
4198// \\ .d,4198 \\ .e,
4199// \\ .e,4199 \\ => f,
4200// \\ => f,4200 \\};
4201// \\};4201 \\
4202// \\4202 );
4203// );4203}
4204//}
42054204
4206test "zig fmt: error for invalid bit range" {4205test "zig fmt: error for invalid bit range" {
4207 try testError(4206 try testError(