fix zig fmt out of bounds on empty file

This commit is contained in:
Vexu 2020-05-30 23:07:04 +03:00
parent 51682717d7
commit 010c58e303
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC
2 changed files with 8 additions and 0 deletions

View File

@ -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 "" {

View File

@ -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];