mirror of
https://github.com/ziglang/zig.git
synced 2025-12-18 20:23:07 +00:00
zig fmt: fix 0 element struct and array init
This commit is contained in:
parent
5df7fc36c6
commit
515d4920e7
@ -796,8 +796,11 @@ pub const Tree = struct {
|
|||||||
.StructInitOne,
|
.StructInitOne,
|
||||||
=> {
|
=> {
|
||||||
end_offset += 1; // rbrace
|
end_offset += 1; // rbrace
|
||||||
|
if (datas[n].rhs == 0) {
|
||||||
|
return main_tokens[n] + end_offset;
|
||||||
|
} else {
|
||||||
n = datas[n].rhs;
|
n = datas[n].rhs;
|
||||||
assert(n != 0);
|
}
|
||||||
},
|
},
|
||||||
.SliceOpen,
|
.SliceOpen,
|
||||||
.CallOneComma,
|
.CallOneComma,
|
||||||
|
|||||||
@ -464,6 +464,15 @@ test "zig fmt: anon literal in array" {
|
|||||||
// );
|
// );
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
test "zig fmt: anon struct literal 0 element" {
|
||||||
|
try testCanonical(
|
||||||
|
\\test {
|
||||||
|
\\ const x = .{};
|
||||||
|
\\}
|
||||||
|
\\
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test "zig fmt: anon struct literal 1 element" {
|
test "zig fmt: anon struct literal 1 element" {
|
||||||
try testCanonical(
|
try testCanonical(
|
||||||
\\test {
|
\\test {
|
||||||
@ -527,6 +536,15 @@ test "zig fmt: anon struct literal 3 element comma" {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "zig fmt: struct literal 0 element" {
|
||||||
|
try testCanonical(
|
||||||
|
\\test {
|
||||||
|
\\ const x = X{};
|
||||||
|
\\}
|
||||||
|
\\
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test "zig fmt: struct literal 1 element" {
|
test "zig fmt: struct literal 1 element" {
|
||||||
try testCanonical(
|
try testCanonical(
|
||||||
\\test {
|
\\test {
|
||||||
@ -653,6 +671,15 @@ test "zig fmt: anon list literal 3 element comma" {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "zig fmt: array literal 0 element" {
|
||||||
|
try testCanonical(
|
||||||
|
\\test {
|
||||||
|
\\ const x = [_]u32{};
|
||||||
|
\\}
|
||||||
|
\\
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test "zig fmt: array literal 1 element" {
|
test "zig fmt: array literal 1 element" {
|
||||||
try testCanonical(
|
try testCanonical(
|
||||||
\\test {
|
\\test {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user