stage2: ensure 'std', 'builtin', and 'root' is always available to @import

This commit is contained in:
Meghan
2022-06-14 14:36:19 -07:00
committed by Andrew Kelley
parent 0fc79d602b
commit 02acde99a1
3 changed files with 9 additions and 21 deletions

View File

@@ -4673,6 +4673,15 @@ pub fn importFile(
cur_file: *File,
import_string: []const u8,
) !ImportFileResult {
if (std.mem.eql(u8, import_string, "std")) {
return mod.importPkg(mod.main_pkg.table.get("std").?);
}
if (std.mem.eql(u8, import_string, "builtin")) {
return mod.importPkg(mod.main_pkg.table.get("builtin").?);
}
if (std.mem.eql(u8, import_string, "root")) {
return mod.importPkg(mod.root_pkg);
}
if (cur_file.pkg.table.get(import_string)) |pkg| {
return mod.importPkg(pkg);
}