w6c+selfhost: cross-module same-leaf type disambiguation via Sym.mod

This commit is contained in:
2026-05-15 10:26:20 +09:00
parent e349536f62
commit 66d6408cbe
15 changed files with 614 additions and 60 deletions

View File

@@ -0,0 +1,19 @@
// Negative case: declare `b: mod1.stream` then access a mod2-only
// field. With the mod-tagged scope lookup `b` resolves to mod1.stream
// (fields a, b), so the field access `b.c` must be a compile-time
// error rather than silently binding to mod2.stream and succeeding.
//
// No cross-module call is made: a missing mod1.make would itself
// trigger a link-time error that could mask the field-resolution
// error this test is actually pinning. `let b: mod1.stream;` is
// enough — we read b.c before initializing it, which is fine because
// the field-resolution error fires at check, long before any reach
// analysis or codegen runs.
use mod1;
use mod2;
fn main() i32 = {
let b: mod1.stream;
return b.c; // mod1.stream has no `c`; expect a compile error.
};