mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
fix zig fmt out of bounds on empty file
This commit is contained in:
parent
51682717d7
commit
010c58e303
@ -223,6 +223,12 @@ test "recovery: missing block after for/while loops" {
|
||||
});
|
||||
}
|
||||
|
||||
test "zig fmt: empty file" {
|
||||
try testCanonical(
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: if statment" {
|
||||
try testCanonical(
|
||||
\\test "" {
|
||||
|
||||
@ -82,6 +82,8 @@ fn renderRoot(
|
||||
var start_col: usize = 0;
|
||||
var decl_i: ast.NodeIndex = 0;
|
||||
const root_decls = tree.root_node.decls();
|
||||
|
||||
if (root_decls.len == 0) return;
|
||||
while (true) {
|
||||
var decl = root_decls[decl_i];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user