zig fmt: fix regression with many container members

This commit is contained in:
Andrew Kelley 2021-02-09 22:42:00 -07:00
parent 9d87e6aeb8
commit fa5fcdd734
3 changed files with 19 additions and 22 deletions

View File

@ -1409,7 +1409,7 @@ pub const Tree = struct {
return tree.fullContainerDecl(.{
.main_token = main_token,
.enum_token = main_token + 2, // union lparen enum
.members = tree.extra_data[data.lhs..data.rhs],
.members = tree.extra_data[members_range.start..members_range.end],
.arg = data.lhs,
});
}

View File

@ -3609,10 +3609,7 @@ const Parser = struct {
.main_token = main_token,
.data = .{
.lhs = enum_tag_expr,
.rhs = try p.addExtra(Node.SubRange{
.start = members_span.start,
.end = members_span.end,
}),
.rhs = try p.addExtra(members_span),
},
});
} else {

View File

@ -734,23 +734,23 @@ test "zig fmt: while else err prong with no block" {
);
}
//test "zig fmt: tagged union with enum values" {
// try testCanonical(
// \\const MultipleChoice2 = union(enum(u32)) {
// \\ Unspecified1: i32,
// \\ A: f32 = 20,
// \\ Unspecified2: void,
// \\ B: bool = 40,
// \\ Unspecified3: i32,
// \\ C: i8 = 60,
// \\ Unspecified4: void,
// \\ D: void = 1000,
// \\ Unspecified5: i32,
// \\};
// \\
// );
//}
//
test "zig fmt: tagged union with enum values" {
try testCanonical(
\\const MultipleChoice2 = union(enum(u32)) {
\\ Unspecified1: i32,
\\ A: f32 = 20,
\\ Unspecified2: void,
\\ B: bool = 40,
\\ Unspecified3: i32,
\\ C: i8 = 60,
\\ Unspecified4: void,
\\ D: void = 1000,
\\ Unspecified5: i32,
\\};
\\
);
}
//test "zig fmt: allowzero pointer" {
// try testCanonical(
// \\const T = [*]allowzero const u8;