authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-28 17:42:23-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 19:49:08-07:00
log196ddf010c97f2faf69513e61099a233d4270795
tree14a3e4630e0cba5cab0434b7717bea092b5123c4
parent8fa44969095caa293cb76b9a0b5fc0c0c270dc3b

frontend: fix populateTestFunctions accessing the wrong module

The test runner reads the list of test function pointers from its own builtin module, which is the root_mod, not main_mod.

2 files changed, 4 insertions(+), 1 deletions(-)

src/Module.zig+1-1
......@@ -5307,7 +5307,7 @@ pub fn populateTestFunctions(
53075307) !void {
53085308 const gpa = mod.gpa;
53095309 const ip = &mod.intern_pool;
5310 const builtin_mod = mod.main_mod.getBuiltinDependency();
5310 const builtin_mod = mod.root_mod.getBuiltinDependency();
53115311 const builtin_file = (mod.importPkg(builtin_mod) catch unreachable).file;
53125312 const root_decl = mod.declPtr(builtin_file.root_decl.unwrap().?);
53135313 const builtin_namespace = mod.namespacePtr(root_decl.src_namespace);
src/Package/Module.zig+3
......@@ -466,6 +466,9 @@ pub fn createLimited(gpa: Allocator, options: LimitedOptions) Allocator.Error!*P
466466 return mod;
467467}
468468
469/// Asserts that the module has a builtin module, which is not true for non-zig
470/// modules such as ones only used for `@embedFile`, or the root module when
471/// there is no Zig Compilation Unit.
469472pub fn getBuiltinDependency(m: Module) *Module {
470473 const result = m.deps.values()[0];
471474 assert(result.isBuiltin());