authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-09-13 13:49:32+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-09-16 00:07:07+02:00
loge5ce236208f97a07347fdab7e7fc88c85e62113b
tree72b7f537f86c634252280c3e0b72e4a0c013e304
parent872800c0a5eecf5f919942dc35df7af7bd4b0be3

Zcu: report multi-module errors against correct file

We were incorrectly using the second referencer as the file to report against, when it was meant to be the file with the ambiguous module. I somehow didn't notice this when writing the tests and was explicitly testing the wrong thing!

3 files changed, 7 insertions(+), 7 deletions(-)

src/Zcu/PerThread.zig+1-1
......@@ -2709,7 +2709,7 @@ fn computeAliveFiles(pt: Zcu.PerThread) Allocator.Error!bool {
27092709 // have a huge number of them by transitive imports, so just reporting this one
27102710 // hopefully keeps the error focused.
27112711 zcu.multi_module_err = .{
2712 .file = file_idx,
2712 .file = res.file,
27132713 .modules = .{ imported_file.mod.?, imported_mod },
27142714 .refs = .{ gop.value_ptr.*, imported_ref },
27152715 };
test/compile_errors.zig+4-4
......@@ -126,10 +126,10 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
126126 \\ _ = @import("foo.zig");
127127 \\}
128128 , &[_][]const u8{
129 ":1:1: error: file exists in modules 'foo' and 'root'",
130 ":1:1: note: files must belong to only one module",
131 ":1:1: note: file is the root of module 'foo'",
132 ":3:17: note: file is imported here by the root of module 'root'",
129 "foo.zig:1:1: error: file exists in modules 'foo' and 'root'",
130 "foo.zig:1:1: note: files must belong to only one module",
131 "foo.zig:1:1: note: file is the root of module 'foo'",
132 "tmp.zig:3:17: note: file is imported here by the root of module 'root'",
133133 });
134134 case.addSourceFile("foo.zig",
135135 \\const dummy = 0;
test/incremental/change_module+2-2
......@@ -43,8 +43,8 @@ pub fn main() void {
4343comptime {
4444 _ = @import("other.zig");
4545}
46#expect_error=foo.zig:1:1: error: file exists in modules 'root' and 'foo'
47#expect_error=foo.zig:1:1: note: files must belong to only one module
46#expect_error=other.zig:1:1: error: file exists in modules 'root' and 'foo'
47#expect_error=other.zig:1:1: note: files must belong to only one module
4848#expect_error=main.zig:3:17: note: file is imported here by the root of module 'root'
4949#expect_error=foo.zig:2:17: note: file is imported here by the root of module 'foo'
5050