Skip to content

Commit f7784a0

Browse files
authored
stage2: fix panic when the dependency is missing
1 parent 0d96f1f commit f7784a0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Sema.zig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10379,7 +10379,9 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1037910379
}
1038010380
}
1038110381
unreachable;
10382-
} else unreachable;
10382+
} else {
10383+
return sema.fail(block, operand_src, "no package named '{s}' available", .{operand});
10384+
};
1038310385
return sema.fail(block, operand_src, "no package named '{s}' available within package '{s}'", .{ operand, parent });
1038410386
},
1038510387
else => {

src/main.zig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,8 +2750,22 @@ fn buildOutputType(
27502750

27512751
// Transfer packages added with --pkg-begin/--pkg-end to the root package
27522752
if (main_pkg) |pkg| {
2753+
var it = pkg_tree_root.table.valueIterator();
2754+
while (it.next()) |p| {
2755+
if (p.*.parent == &pkg_tree_root) {
2756+
p.*.parent = pkg;
2757+
}
2758+
}
27532759
pkg.table = pkg_tree_root.table;
27542760
pkg_tree_root.table = .{};
2761+
} else {
2762+
// Remove any dangling pointers just in case.
2763+
var it = pkg_tree_root.table.valueIterator();
2764+
while (it.next()) |p| {
2765+
if (p.*.parent == &pkg_tree_root) {
2766+
p.*.parent = null;
2767+
}
2768+
}
27552769
}
27562770

27572771
const self_exe_path = try introspect.findZigExePath(arena);

0 commit comments

Comments
 (0)