zig fmt: improve handling of comptime tuple fields

This commit is contained in:
Veikka Tuominen
2022-12-27 13:52:37 +02:00
parent 547e3684be
commit af9a9a1374
4 changed files with 21 additions and 7 deletions

View File

@@ -1,7 +1,9 @@
test "zig fmt: tuple struct" {
try testCanonical(
\\const T = struct {
\\ comptime u32,
\\ /// doc comment on tuple field
\\ comptime comptime u32,
\\ /// another doc comment on tuple field
\\ *u32 = 1,
\\ // needs to be wrapped in parentheses to not be parsed as a function decl
\\ (fn () void) align(1),
@@ -4238,6 +4240,18 @@ test "zig fmt: remove newlines surrounding doc comment within container decl" {
);
}
test "zig fmt: comptime before comptime field" {
try testError(
\\const Foo = struct {
\\ a: i32,
\\ comptime comptime b: i32 = 1234,
\\};
\\
, &[_]Error{
.expected_comma_after_field,
});
}
test "zig fmt: invalid else branch statement" {
try testError(
\\/// This is a doc comment for a comptime block.