diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2023-02-18 04:10:50 +0000 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2023-02-21 02:05:35 +0000 |
| commit | b8a96baab887e4dcd54d49fb1bbc8294af47392e (patch) | |
| tree | 215e79bf64294803dd70edb5f3bdd6225f3bdcfe /src/Module.zig | |
| parent | 09a84c8384dffc7884528947b879f32d93c1bd90 (diff) | |
| download | zig-b8a96baab887e4dcd54d49fb1bbc8294af47392e.tar.gz zig-b8a96baab887e4dcd54d49fb1bbc8294af47392e.zip | |
Improve multi-module error messages
- Fix assertion failure if AstGen failed on a multi-module file
- Cap number of per-error reference notes and total multi-module errors each at 5
- Always put "root of package" reference notes first
Resolves: #14499
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Module.zig b/src/Module.zig index 2afe3f5df1..a2502d36d3 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1946,7 +1946,7 @@ pub const File = struct { prev_zir: ?*Zir = null, /// A single reference to a file. - const Reference = union(enum) { + pub const Reference = union(enum) { /// The file is imported directly (i.e. not as a package) with @import. import: SrcLoc, /// The file is the root of a package. @@ -2144,7 +2144,10 @@ pub const File = struct { file.multi_pkg = true; file.status = .astgen_failure; - std.debug.assert(file.zir_loaded); + // We can only mark children as failed if the ZIR is loaded, which may not + // be the case if there were other astgen failures in this file + if (!file.zir_loaded) return; + const imports_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.imports)]; if (imports_index == 0) return; const extra = file.zir.extraData(Zir.Inst.Imports, imports_index); |
