commit 9f086f84f53de4eb23d96fe611c071f27405a660 (tree)
parent 8f849684f46ad0835bd9591f420e49e212880cb2
Author: mlugg <mlugg@mlugg.co.uk>
Date: Fri, 6 Dec 2024 06:22:32 +0000
Zcu: allow test declarations to be failed
The introduction of the `extended(astgen_error())` instruction allows a
`test` declaration to be unresolved, i.e. the declaration doesn't even
contain a `func`. I could modify AstGen to not do this, but it makes
more sense to just handle this case when collecting test functions.
Note that tests under incremental compilation are currently broken if
you ever remove all references to a test; this is tracked as a subtask
of #21165.
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig
@@ -2511,6 +2511,19 @@ pub fn populateTestFunctions(
for (test_fn_vals, zcu.test_functions.keys()) |*test_fn_val, test_nav_index| {
const test_nav = ip.getNav(test_nav_index);
+
+ {
+ // The test declaration might have failed; if that's the case, just return, as we'll
+ // be emitting a compile error anyway.
+ const cau = test_nav.analysis_owner.unwrap().?;
+ const anal_unit: AnalUnit = .wrap(.{ .cau = cau });
+ if (zcu.failed_analysis.contains(anal_unit) or
+ zcu.transitive_failed_analysis.contains(anal_unit))
+ {
+ return;
+ }
+ }
+
const test_nav_name = test_nav.fqn;
const test_nav_name_len = test_nav_name.length(ip);
const test_name_anon_decl: InternPool.Key.Ptr.BaseAddr.Uav = n: {