| ... | @@ -9839,6 +9839,21 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -9839,6 +9839,21 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 9839 | error.ImportOutsidePkgPath => { | 9839 | error.ImportOutsidePkgPath => { |
| 9840 | return sema.fail(block, operand_src, "import of file outside package path: '{s}'", .{operand}); | 9840 | return sema.fail(block, operand_src, "import of file outside package path: '{s}'", .{operand}); |
| 9841 | }, | 9841 | }, |
| | 9842 | error.PackageNotFound => { |
| | 9843 | const cur_pkg = block.getFileScope().pkg; |
| | 9844 | const parent = if (cur_pkg == sema.mod.main_pkg or cur_pkg == sema.mod.root_pkg) |
| | 9845 | "root" |
| | 9846 | else if (cur_pkg.parent) |parent| blk: { |
| | 9847 | var it = parent.table.iterator(); |
| | 9848 | while (it.next()) |pkg| { |
| | 9849 | if (pkg.value_ptr.* == cur_pkg) { |
| | 9850 | break :blk pkg.key_ptr.*; |
| | 9851 | } |
| | 9852 | } |
| | 9853 | unreachable; |
| | 9854 | } else unreachable; |
| | 9855 | return sema.fail(block, operand_src, "no package named '{s}' available within package '{s}'", .{ operand, parent }); |
| | 9856 | }, |
| 9842 | else => { | 9857 | else => { |
| 9843 | // TODO: these errors are file system errors; make sure an update() will | 9858 | // TODO: these errors are file system errors; make sure an update() will |
| 9844 | // retry this and not cache the file system error, which may be transient. | 9859 | // retry this and not cache the file system error, which may be transient. |