authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-12-06 06:22:32+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-12-06 06:22:32+00:00
log9f086f84f53de4eb23d96fe611c071f27405a660
treeaa40346ae5fdadd6121fef59aa203c88cd744956
parent8f849684f46ad0835bd9591f420e49e212880cb2
signaturelock-open Commit is signed but in an unrecognized format.

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.

1 files changed, 13 insertions(+), 0 deletions(-)

src/Zcu/PerThread.zig+13
......@@ -2511,6 +2511,19 @@ pub fn populateTestFunctions(
25112511
25122512 for (test_fn_vals, zcu.test_functions.keys()) |*test_fn_val, test_nav_index| {
25132513 const test_nav = ip.getNav(test_nav_index);
2514
2515 {
2516 // The test declaration might have failed; if that's the case, just return, as we'll
2517 // be emitting a compile error anyway.
2518 const cau = test_nav.analysis_owner.unwrap().?;
2519 const anal_unit: AnalUnit = .wrap(.{ .cau = cau });
2520 if (zcu.failed_analysis.contains(anal_unit) or
2521 zcu.transitive_failed_analysis.contains(anal_unit))
2522 {
2523 return;
2524 }
2525 }
2526
25142527 const test_nav_name = test_nav.fqn;
25152528 const test_nav_name_len = test_nav_name.length(ip);
25162529 const test_name_anon_decl: InternPool.Key.Ptr.BaseAddr.Uav = n: {