parser: allow unnamed fields in structs

This commit is contained in:
Veikka Tuominen
2022-11-21 23:25:16 +02:00
parent 32ce2f91a9
commit 6fb689e97a
4 changed files with 209 additions and 151 deletions

View File

@@ -1,3 +1,15 @@
test "zig fmt: tuple struct" {
try testCanonical(
\\const T = struct {
\\ comptime u32,
\\ *u32 = 1,
\\ // needs to be wrapped in parentheses to not be parsed as a function decl
\\ (fn () void) align(1),
\\};
\\
);
}
test "zig fmt: preserves clobbers in inline asm with stray comma" {
try testCanonical(
\\fn foo() void {
@@ -265,14 +277,6 @@ test "zig fmt: decl between fields" {
});
}
test "zig fmt: eof after missing comma" {
try testError(
\\foo()
, &[_]Error{
.expected_comma_after_field,
});
}
test "zig fmt: errdefer with payload" {
try testCanonical(
\\pub fn main() anyerror!void {
@@ -5732,8 +5736,8 @@ test "recovery: missing semicolon" {
test "recovery: invalid container members" {
try testError(
\\usingnamespace;
\\foo+
\\bar@,
\\@foo()+
\\@bar()@,
\\while (a == 2) { test "" {}}
\\test "" {
\\ a & b
@@ -5741,7 +5745,7 @@ test "recovery: invalid container members" {
, &[_]Error{
.expected_expr,
.expected_comma_after_field,
.expected_container_members,
.expected_type_expr,
.expected_semi_after_stmt,
});
}