diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig index 1b78db9f3e..cbc12122c6 100644 --- a/lib/std/zig/ast.zig +++ b/lib/std/zig/ast.zig @@ -408,10 +408,10 @@ pub const Tree = struct { const main_token = main_tokens[n]; return switch (token_tags[main_token]) { .Asterisk => switch (token_tags[main_token - 1]) { - .LBrace => main_token - 1, + .LBracket => main_token - 1, else => main_token, }, - .LBrace => main_token, + .LBracket => main_token, else => unreachable, } - end_offset; }, diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index cc27b49f41..a0114260db 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -423,16 +423,16 @@ test "zig fmt: sentinel slice with modifiers" { ); } -//test "zig fmt: anon literal in array" { -// try testCanonical( -// \\var arr: [2]Foo = .{ -// \\ .{ .a = 2 }, -// \\ .{ .b = 3 }, -// \\}; -// \\ -// ); -//} -// +test "zig fmt: anon literal in array" { + try testCanonical( + \\var arr: [2]Foo = .{ + \\ .{ .a = 2 }, + \\ .{ .b = 3 }, + \\}; + \\ + ); +} + //test "zig fmt: alignment in anonymous literal" { // try testTransform( // \\const a = .{ @@ -751,12 +751,12 @@ test "zig fmt: tagged union with enum values" { ); } -//test "zig fmt: allowzero pointer" { -// try testCanonical( -// \\const T = [*]allowzero const u8; -// \\ -// ); -//} +test "zig fmt: allowzero pointer" { + try testCanonical( + \\const T = [*]allowzero const u8; + \\ + ); +} test "zig fmt: enum literal" { try testCanonical( @@ -806,13 +806,13 @@ test "zig fmt: character literal larger than u8" { // \\ // ); //} -// -//test "zig fmt: C pointers" { -// try testCanonical( -// \\const Ptr = [*c]i32; -// \\ -// ); -//} + +test "zig fmt: C pointers" { + try testCanonical( + \\const Ptr = [*c]i32; + \\ + ); +} test "zig fmt: threadlocal" { try testCanonical(