commit cc82620b2a0c0ca1e3aa1aa35657b626acd468a4 (tree)
parent 13a28345bb6da736c3e4f0a65ef709dfb69fb6f3
Author: Techatrix <techatrix@mailbox.org>
Date: Thu, 12 Dec 2024 22:13:00 +0100
fix std.zig.Ast.rootDecls on .zon mode Ast
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig
@@ -205,9 +205,11 @@ pub fn extraData(tree: Ast, index: usize, comptime T: type) T {
}
pub fn rootDecls(tree: Ast) []const Node.Index {
- // Root is always index 0.
const nodes_data = tree.nodes.items(.data);
- return tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs];
+ return switch (tree.mode) {
+ .zig => tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs],
+ .zon => (&nodes_data[0].lhs)[0..1],
+ };
}
pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {