zig fmt: fix firstToken() for switch_case

This commit is contained in:
Isaac Freund
2021-02-24 12:14:15 +01:00
parent db4c15be50
commit 1b8eca030e
2 changed files with 13 additions and 14 deletions

View File

@@ -580,7 +580,7 @@ pub const Tree = struct {
.switch_case => {
const extra = tree.extraData(datas[n].lhs, Node.SubRange);
assert(extra.end - extra.start > 0);
n = extra.start;
n = tree.extra_data[extra.start];
},
.asm_output, .asm_input => {

View File

@@ -4189,19 +4189,18 @@ test "zig fmt: respect extra newline between fn and pub usingnamespace" {
);
}
// TODO
//test "zig fmt: respect extra newline between switch items" {
// try testCanonical(
// \\const a = switch (b) {
// \\ .c => {},
// \\
// \\ .d,
// \\ .e,
// \\ => f,
// \\};
// \\
// );
//}
test "zig fmt: respect extra newline between switch items" {
try testCanonical(
\\const a = switch (b) {
\\ .c => {},
\\
\\ .d,
\\ .e,
\\ => f,
\\};
\\
);
}
test "zig fmt: error for invalid bit range" {
try testError(