parser: improve error message for missing var/const before local variable

Closes #12721
This commit is contained in:
Veikka Tuominen
2022-10-28 16:09:24 +03:00
parent 1ea1228036
commit 9607bd90e6
3 changed files with 43 additions and 2 deletions

View File

@@ -5145,6 +5145,32 @@ test "zig fmt: make single-line if no trailing comma" {
);
}
test "zig fmt: missing const/var before local variable" {
try testError(
\\comptime {
\\ z: u32;
\\}
\\comptime {
\\ z: u32 align(1);
\\}
\\comptime {
\\ z: u32 addrspace(.generic);
\\}
\\comptime {
\\ z: u32 linksection("foo");
\\}
\\comptime {
\\ z: u32 = 1;
\\}
, &.{
.expected_labelable,
.expected_var_const,
.expected_var_const,
.expected_var_const,
.expected_var_const,
});
}
test "zig fmt: while continue expr" {
try testCanonical(
\\test {