stage2: slightly improve error reporting for missing imports

There is now a distinction between `@import` with a .zig extension and
without. Without a .zig extension it assumes it is a package name, and
returns error.PackageNotFound if not mapped into the package table.
This commit is contained in:
Andrew Kelley
2021-06-22 16:11:02 -07:00
parent 6fb45807ab
commit 150515f44d
3 changed files with 20 additions and 5 deletions

View File

@@ -3185,6 +3185,9 @@ pub fn importFile(
if (cur_file.pkg.table.get(import_string)) |pkg| {
return mod.importPkg(pkg);
}
if (!mem.endsWith(u8, import_string, ".zig")) {
return error.PackageNotFound;
}
const gpa = mod.gpa;
// The resolved path is used as the key in the import table, to detect if