stage2: fix panic when the dependency is missing

This commit is contained in:
riChar 2022-09-02 17:53:48 +08:00 committed by GitHub
parent 0d96f1f4fb
commit f7784a081f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -10379,7 +10379,9 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
}
}
unreachable;
} else unreachable;
} else {
return sema.fail(block, operand_src, "no package named '{s}' available", .{operand});
};
return sema.fail(block, operand_src, "no package named '{s}' available within package '{s}'", .{ operand, parent });
},
else => {

View File

@ -2750,8 +2750,22 @@ fn buildOutputType(
// Transfer packages added with --pkg-begin/--pkg-end to the root package
if (main_pkg) |pkg| {
var it = pkg_tree_root.table.valueIterator();
while (it.next()) |p| {
if (p.*.parent == &pkg_tree_root) {
p.*.parent = pkg;
}
}
pkg.table = pkg_tree_root.table;
pkg_tree_root.table = .{};
} else {
// Remove any dangling pointers just in case.
var it = pkg_tree_root.table.valueIterator();
while (it.next()) |p| {
if (p.*.parent == &pkg_tree_root) {
p.*.parent = null;
}
}
}
const self_exe_path = try introspect.findZigExePath(arena);