Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/std/zig/Ast.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,9 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
if (extra.section_node.unwrap()) |section_node| {
end_offset += 1; // for the rparen
n = section_node;
} else if (extra.addrspace_node.unwrap()) |addrspace_node| {
end_offset += 1; // for the rparen
n = addrspace_node;
} else if (extra.align_node.unwrap()) |align_node| {
end_offset += 1; // for the rparen
n = align_node;
Expand Down
10 changes: 10 additions & 0 deletions lib/std/zig/parser_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6074,6 +6074,16 @@ test "zig fmt: do not canonicalize invalid cast builtins" {
);
}

test "zig fmt: extern addrspace in struct" {
try testCanonical(
\\const namespace = struct {
\\ extern const num: u8 addrspace(.generic);
\\};
\\// comment
\\
);
}

test "recovery: top level" {
try testError(
\\test "" {inline}
Expand Down
Loading