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.
This commit is contained in:
mlugg 2024-12-06 06:22:32 +00:00
parent 8f849684f4
commit 9f086f84f5
No known key found for this signature in database
GPG Key ID: 3F5B7DCCBF4AF02E

View File

@ -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: {