diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-11-15 16:50:20 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-11-16 01:12:28 +0200 |
| commit | fb09093d95f2dc9bf454ba0d1d489316311adffc (patch) | |
| tree | d033652857b160b2862c935fbd498a9f5aa7dfec /src/Module.zig | |
| parent | 2cfa7165e715321dffea21380d4fde0dd5079925 (diff) | |
| download | zig-fb09093d95f2dc9bf454ba0d1d489316311adffc.tar.gz zig-fb09093d95f2dc9bf454ba0d1d489316311adffc.zip | |
Module: call `ensureDeclAnalyzed` on `builtin.test_functions`
Previously the compiler would crash on branching on undefined values
if you tried using `zig test` with a freestanding target since there
was no start code referencing `builtin.test_functions`.
Closes #12554
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig index 3f061491c1..af29a591cc 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -6431,13 +6431,27 @@ pub fn processExports(mod: *Module) !void { } } -pub fn populateTestFunctions(mod: *Module) !void { +pub fn populateTestFunctions( + mod: *Module, + main_progress_node: *std.Progress.Node, +) !void { const gpa = mod.gpa; const builtin_pkg = mod.main_pkg.table.get("builtin").?; const builtin_file = (mod.importPkg(builtin_pkg) catch unreachable).file; const root_decl = mod.declPtr(builtin_file.root_decl.unwrap().?); const builtin_namespace = root_decl.src_namespace; const decl_index = builtin_namespace.decls.getKeyAdapted(@as([]const u8, "test_functions"), DeclAdapter{ .mod = mod }).?; + { + // We have to call `ensureDeclAnalyzed` here in case `builtin.test_functions` + // was not referenced by start code. + mod.sema_prog_node = main_progress_node.start("Semantic Analysis", 0); + mod.sema_prog_node.activate(); + defer { + mod.sema_prog_node.end(); + mod.sema_prog_node = undefined; + } + try mod.ensureDeclAnalyzed(decl_index); + } const decl = mod.declPtr(decl_index); var buf: Type.SlicePtrFieldTypeBuffer = undefined; const tmp_test_fn_ty = decl.ty.slicePtrFieldType(&buf).elemType(); |
