aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-07-20 16:39:13 +0300
committerAndrew Kelley <andrew@ziglang.org>2022-07-28 15:20:01 -0700
commitece1d1daf476fdffc69279c686ad1e2101ce6e4d (patch)
tree7934bd543a744c6f7da7ba9527a7656088d1c3f8
parent02acde99a142e89c30d0e49cc703d0ad80ea31b7 (diff)
downloadzig-ece1d1daf476fdffc69279c686ad1e2101ce6e4d.tar.gz
zig-ece1d1daf476fdffc69279c686ad1e2101ce6e4d.zip
CLI: add error for duplicate package
-rw-r--r--src/main.zig6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index bd86cd2bb9..f2291a0646 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -858,6 +858,12 @@ fn buildOutputType(
) catch |err| {
fatal("Failed to add package at path {s}: {s}", .{ pkg_path.?, @errorName(err) });
};
+
+ if (mem.eql(u8, pkg_name.?, "std") or mem.eql(u8, pkg_name.?, "root") or mem.eql(u8, pkg_name.?, "builtin")) {
+ fatal("unable to add package '{s}' -> '{s}': conflicts with builtin package", .{ pkg_name.?, pkg_path.? });
+ } else if (cur_pkg.table.get(pkg_name.?)) |prev| {
+ fatal("unable to add package '{s}' -> '{s}': already exists as '{s}", .{ pkg_name.?, pkg_path.?, prev.root_src_path });
+ }
try cur_pkg.addAndAdopt(gpa, pkg_name.?, new_cur_pkg);
cur_pkg = new_cur_pkg;
} else if (mem.eql(u8, arg, "--pkg-end")) {