CLI: add error for duplicate package

This commit is contained in:
Veikka Tuominen 2022-07-20 16:39:13 +03:00 committed by Andrew Kelley
parent 02acde99a1
commit ece1d1daf4

View File

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