You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This applies to packed struct(T), union(T), union(enum(T)), and enum(T)
This happens since Ast.lastToken assumes that when these have no members, the only following tokens are ){}. This also means the bug may also observable in other parts of the compiler, but it is easiest to observe with zig fmt.
Expected Behavior
No change.
The text was updated successfully, but these errors were encountered:
gooncreeper
changed the title
zig fmt: wrong output for empty containers with document comments
zig fmt: wrong output for tagged empty containers with document comments
May 4, 2025
Adds a new fuzz test for zig fmt. This fuzz test checks that Ast.render
succeeds for parsed inputs. Additionally, for inputs it knows that
Ast.render cannot change the order of, it checks that they are not
rewritten.
This fuzz test has been very successful. Using ziglang#23416, it has found
three bugs (one was a TODO); two of them I have fixed and the other is
in ziglang#23754. I have run the test for 650,000,000 iterations (about 2
hours) and haven't found any more bugs.
Some functions in the fuzz test have instrumentation disabled because
their branches are not interesting to the fuzzer; doing this found a
~40% boost to the runs per second. Additionally, the fuzz test handles
tokenization itself since so it can determine if the input can be
rewritten.
Uh oh!
There was an error while loading. Please reload this page.
Zig Version
0.15.0-dev.451+a843be44a
Steps to Reproduce and Observed Behavior
Run
zig fmt
on the following code,It incorrectly formats it to
This applies to
packed struct(T)
,union(T)
,union(enum(T))
, andenum(T)
This happens since
Ast.lastToken
assumes that when these have no members, the only following tokens are){}
. This also means the bug may also observable in other parts of the compiler, but it is easiest to observe withzig fmt
.Expected Behavior
No change.
The text was updated successfully, but these errors were encountered: