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!
This commit is contained in:
Matthew Lugg authored and mlugg committed 2026-09-16 00:07:07 +02:00
1 parent 872800c0a5
commit e5ce236208
3 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -2709,7 +2709,7 @@ fn computeAliveFiles(pt: Zcu.PerThread) Allocator.Error!bool {
// have a huge number of them by transitive imports, so just reporting this one
// hopefully keeps the error focused.
zcu.multi_module_err = .{
.file = file_idx,
.file = res.file,
.modules = .{ imported_file.mod.?, imported_mod },
.refs = .{ gop.value_ptr.*, imported_ref },
};
+4 -4
View File
@@ -126,10 +126,10 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
\\ _ = @import("foo.zig");
\\}
, &[_][]const u8{
":1:1: error: file exists in modules 'foo' and 'root'",
":1:1: note: files must belong to only one module",
":1:1: note: file is the root of module 'foo'",
":3:17: note: file is imported here by the root of module 'root'",
"foo.zig:1:1: error: file exists in modules 'foo' and 'root'",
"foo.zig:1:1: note: files must belong to only one module",
"foo.zig:1:1: note: file is the root of module 'foo'",
"tmp.zig:3:17: note: file is imported here by the root of module 'root'",
});
case.addSourceFile("foo.zig",
\\const dummy = 0;
+2 -2
View File
@@ -43,8 +43,8 @@ pub fn main() void {
comptime {
_ = @import("other.zig");
}
#expect_error=foo.zig:1:1: error: file exists in modules 'root' and 'foo'
#expect_error=foo.zig:1:1: note: files must belong to only one module
#expect_error=other.zig:1:1: error: file exists in modules 'root' and 'foo'
#expect_error=other.zig:1:1: note: files must belong to only one module
#expect_error=main.zig:3:17: note: file is imported here by the root of module 'root'
#expect_error=foo.zig:2:17: note: file is imported here by the root of module 'foo'