diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-12-09 18:32:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-09 18:32:23 -0500 |
| commit | 7575f212128df84c8b86ee3c89d940313380d902 (patch) | |
| tree | fc060baccfbfbb24946779a0795c6c29d9d9bf92 /src/Compilation.zig | |
| parent | 8245d7fac0400d7e9de2a6fd4cfbc3609ad0f201 (diff) | |
| parent | 9f086f84f53de4eb23d96fe611c071f27405a660 (diff) | |
| download | zig-7575f212128df84c8b86ee3c89d940313380d902.tar.gz zig-7575f212128df84c8b86ee3c89d940313380d902.zip | |
Merge pull request #22157 from mlugg/astgen-error-lazy
compiler: allow semantic analysis of files with AstGen errors
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 369d886f24..0a8e1ef157 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3223,17 +3223,29 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { } } - if (comp.zcu) |zcu| { - if (comp.incremental and bundle.root_list.items.len == 0) { - const should_have_error = for (zcu.transitive_failed_analysis.keys()) |failed_unit| { - const refs = try zcu.resolveReferences(); - if (refs.contains(failed_unit)) break true; - } else false; - if (should_have_error) { - @panic("referenced transitive analysis errors, but none actually emitted"); + // TODO: eventually, this should be behind `std.debug.runtime_safety`. But right now, this is a + // very common way for incremental compilation bugs to manifest, so let's always check it. + if (comp.zcu) |zcu| if (comp.incremental and bundle.root_list.items.len == 0) { + for (zcu.transitive_failed_analysis.keys()) |failed_unit| { + const refs = try zcu.resolveReferences(); + var ref = refs.get(failed_unit) orelse continue; + // This AU is referenced and has a transitive compile error, meaning it referenced something with a compile error. + // However, we haven't reported any such error. + // This is a compiler bug. + const stderr = std.io.getStdErr().writer(); + try stderr.writeAll("referenced transitive analysis errors, but none actually emitted\n"); + try stderr.print("{} [transitive failure]\n", .{zcu.fmtAnalUnit(failed_unit)}); + while (ref) |r| { + try stderr.print("referenced by: {}{s}\n", .{ + zcu.fmtAnalUnit(r.referencer), + if (zcu.transitive_failed_analysis.contains(r.referencer)) " [transitive failure]" else "", + }); + ref = refs.get(r.referencer).?; } + + @panic("referenced transitive analysis errors, but none actually emitted"); } - } + }; const compile_log_text = if (comp.zcu) |m| m.compile_log_text.items else ""; return bundle.toOwnedBundle(compile_log_text); |
