mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
Prevent unreachable when file ends with struct field
This commit is contained in:
parent
9471f16c79
commit
7f618184ad
@ -2258,6 +2258,15 @@ test "zig fmt: if type expr" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: file ends with struct field" {
|
||||
try testTransform(
|
||||
\\a: bool
|
||||
,
|
||||
\\a: bool,
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const warn = std.debug.warn;
|
||||
|
||||
@ -1899,7 +1899,7 @@ fn renderTokenOffset(
|
||||
return renderToken(tree, stream, token_index + 1, indent, start_col, Space.Newline);
|
||||
},
|
||||
else => {
|
||||
if (tree.tokens.at(token_index + 2).id == Token.Id.MultilineStringLiteralLine) {
|
||||
if (token_index + 2 < tree.tokens.len and tree.tokens.at(token_index + 2).id == Token.Id.MultilineStringLiteralLine) {
|
||||
try stream.write(",");
|
||||
return;
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user