Skip to content

Commit

Permalink
fix DocumentScope on invalid .zon files
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Dec 12, 2024
1 parent 475463a commit a74eda0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/DocumentScope.zig
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,19 @@ pub fn init(allocator: std.mem.Allocator, tree: Ast) error{OutOfMemory}!Document
.doc_scope = &document_scope,
};
defer context.deinit();
try walkContainerDecl(&context, tree, 0);
switch (tree.mode) {
.zig => try walkContainerDecl(&context, tree, 0),
.zon => {
const root_node = tree.nodes.items(.data)[0].lhs;
const new_scope = try context.startScope(
.other,
.{ .ast_node = root_node },
.{ .start = 0, .end = @intCast(tree.source.len) },
);
try walkNode(&context, tree, root_node);
try new_scope.finalize();
},
}

return document_scope;
}
Expand Down

0 comments on commit a74eda0

Please sign in to comment.