diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-06-22 16:11:02 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-06-23 10:44:46 -0700 |
| commit | 150515f44db9cecbda31d579861dc6f6080c2f75 (patch) | |
| tree | 859145a3479f7e9880269b2ef945bfce3043ccf3 /src/Module.zig | |
| parent | 6fb45807abab49982c12b71112e9acb39cf94270 (diff) | |
| download | zig-150515f44db9cecbda31d579861dc6f6080c2f75.tar.gz zig-150515f44db9cecbda31d579861dc6f6080c2f75.zip | |
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.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig index 5e94382648..e168f6aac7 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -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 |
