Skip to content

Commit b9c6088

Browse files
committed
zig std / std.zig.Ast: count addrspace tokens correctly
1 parent 155b34b commit b9c6088

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/std/zig/Ast.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,9 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
12131213
if (extra.section_node.unwrap()) |section_node| {
12141214
end_offset += 1; // for the rparen
12151215
n = section_node;
1216+
} else if (extra.addrspace_node.unwrap()) |addrspace_node| {
1217+
end_offset += 1; // for the rparen
1218+
n = addrspace_node;
12161219
} else if (extra.align_node.unwrap()) |align_node| {
12171220
end_offset += 1; // for the rparen
12181221
n = align_node;

lib/std/zig/parser_test.zig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6107,6 +6107,16 @@ test "zig fmt: indentation of comments within catch, else, orelse" {
61076107
);
61086108
}
61096109

6110+
test "zig fmt: extern addrspace in struct" {
6111+
try testCanonical(
6112+
\\const namespace = struct {
6113+
\\ extern const num: u8 addrspace(.generic);
6114+
\\};
6115+
\\// comment
6116+
\\
6117+
);
6118+
}
6119+
61106120
test "recovery: top level" {
61116121
try testError(
61126122
\\test "" {inline}

0 commit comments

Comments
 (0)