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 {...@@ -2709,7 +2709,7 @@ fn computeAliveFiles(pt: Zcu.PerThread) Allocator.Error!bool {
2709 // have a huge number of them by transitive imports, so just reporting this one2709 // have a huge number of them by transitive imports, so just reporting this one
2710 // hopefully keeps the error focused.2710 // hopefully keeps the error focused.
2711 zcu.multi_module_err = .{2711 zcu.multi_module_err = .{
2712 .file = file_idx,2712 .file = res.file,
2713 .modules = .{ imported_file.mod.?, imported_mod },2713 .modules = .{ imported_file.mod.?, imported_mod },
2714 .refs = .{ gop.value_ptr.*, imported_ref },2714 .refs = .{ gop.value_ptr.*, imported_ref },
2715 };2715 };
test/compile_errors.zig+4-4
...@@ -126,10 +126,10 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {...@@ -126,10 +126,10 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
126 \\ _ = @import("foo.zig");126 \\ _ = @import("foo.zig");
127 \\}127 \\}
128 , &[_][]const u8{128 , &[_][]const u8{
129 ":1:1: error: file exists in modules 'foo' and 'root'",129 "foo.zig:1:1: error: file exists in modules 'foo' and 'root'",
130 ":1:1: note: files must belong to only one module",130 "foo.zig:1:1: note: files must belong to only one module",
131 ":1:1: note: file is the root of module 'foo'",131 "foo.zig:1:1: note: file is the root of module 'foo'",
132 ":3:17: note: file is imported here by the root of module 'root'",132 "tmp.zig:3:17: note: file is imported here by the root of module 'root'",
133 });133 });
134 case.addSourceFile("foo.zig",134 case.addSourceFile("foo.zig",
135 \\const dummy = 0;135 \\const dummy = 0;
test/incremental/change_module+2-2
...@@ -43,8 +43,8 @@ pub fn main() void {...@@ -43,8 +43,8 @@ pub fn main() void {
43comptime {43comptime {
44 _ = @import("other.zig");44 _ = @import("other.zig");
45}45}
46#expect_error=foo.zig:1:1: error: file exists in modules 'root' and 'foo'46#expect_error=other.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 module47#expect_error=other.zig:1:1: note: files must belong to only one module
48#expect_error=main.zig:3:17: note: file is imported here by the root of module 'root'48#expect_error=main.zig:3:17: note: file is imported here by the root of module 'root'
49#expect_error=foo.zig:2:17: note: file is imported here by the root of module 'foo'49#expect_error=foo.zig:2:17: note: file is imported here by the root of module 'foo'
5050