aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/std/Build.zig4
-rw-r--r--lib/std/array_hash_map.zig3
-rw-r--r--lib/std/zig/Ast.zig4
-rw-r--r--lib/std/zig/Parse.zig13
4 files changed, 19 insertions, 5 deletions
diff --git a/lib/std/Build.zig b/lib/std/Build.zig
index d695637fc3..6846007443 100644
--- a/lib/std/Build.zig
+++ b/lib/std/Build.zig
@@ -1496,8 +1496,8 @@ pub fn dependency(b: *Build, name: []const u8, args: anytype) *Dependency {
}
}
- const full_path = b.pathFromRoot("build.zig.ini");
- std.debug.print("no dependency named '{s}' in '{s}'\n", .{ name, full_path });
+ const full_path = b.pathFromRoot("build.zig.zon");
+ std.debug.print("no dependency named '{s}' in '{s}'. All packages used in build.zig must be declared in this file.\n", .{ name, full_path });
std.process.exit(1);
}
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig
index cf04a54116..57821d1b51 100644
--- a/lib/std/array_hash_map.zig
+++ b/lib/std/array_hash_map.zig
@@ -1145,7 +1145,8 @@ pub fn ArrayHashMapUnmanaged(
}
/// Create a copy of the hash map which can be modified separately.
- /// The copy uses the same context and allocator as this instance.
+ /// The copy uses the same context as this instance, but is allocated
+ /// with the provided allocator.
pub fn clone(self: Self, allocator: Allocator) !Self {
if (@sizeOf(ByIndexContext) != 0)
@compileError("Cannot infer context " ++ @typeName(Context) ++ ", call cloneContext instead.");
diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig
index a9a02606eb..80dda052ab 100644
--- a/lib/std/zig/Ast.zig
+++ b/lib/std/zig/Ast.zig
@@ -1,4 +1,8 @@
//! Abstract Syntax Tree for Zig source code.
+//! For Zig syntax, the root node is at nodes[0] and contains the list of
+//! sub-nodes.
+//! For Zon syntax, the root node is at nodes[0] and contains lhs as the node
+//! index of the main expression.
/// Reference to externally-owned data.
source: [:0]const u8,
diff --git a/lib/std/zig/Parse.zig b/lib/std/zig/Parse.zig
index f599a08f55..d498366b34 100644
--- a/lib/std/zig/Parse.zig
+++ b/lib/std/zig/Parse.zig
@@ -181,17 +181,26 @@ pub fn parseRoot(p: *Parse) !void {
/// TODO: set a flag in Parse struct, and honor that flag
/// by emitting compilation errors when non-zon nodes are encountered.
pub fn parseZon(p: *Parse) !void {
- const node_index = p.parseExpr() catch |err| switch (err) {
+ // We must use index 0 so that 0 can be used as null elsewhere.
+ p.nodes.appendAssumeCapacity(.{
+ .tag = .root,
+ .main_token = 0,
+ .data = undefined,
+ });
+ const node_index = p.expectExpr() catch |err| switch (err) {
error.ParseError => {
assert(p.errors.items.len > 0);
return;
},
else => |e| return e,
};
- assert(node_index == 0);
if (p.token_tags[p.tok_i] != .eof) {
try p.warnExpected(.eof);
}
+ p.nodes.items(.data)[0] = .{
+ .lhs = node_index,
+ .rhs = undefined,
+ };
}
/// ContainerMembers <- ContainerDeclarations (ContainerField COMMA)* (ContainerField / ContainerDeclarations)