diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index bb00d4a9..f01a0f77 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -7607,7 +7607,16 @@ fn resolvealias(c: *checker, n: *node) *node = { leaf.len = nm.len - dotidx - 1; s = scopelookupinmodule(c.cur, head, leaf); } else { - s = scopelookup(c.cur, nm); + // #53: same-module preference. Mirrors cstage + // cmd/wcc/check.c:66 scope_lookup_prefer. Without this, + // two modules each declaring `type invalid = ...` collide + // on the head-first bucket walk: e.g. utf8.invalid `!void` + // vs strconv.invalid `!i32` resolves to whichever + // registered first, driving localloadop MOVSXD/MOVQ + // divergence at 994/995. Other bare-leaf callers in this + // file (L1597 exprtype N_IDENT, L1795/L2720 N_DOT-callee + // leaf, L600 varianterr, L647 scruttype) tracked as #55. + s = scopelookupprefer(c.cur, c.curmod, nm); // #61 A.5: bare TNAME that collides with an imported // module bareword. Two shapes hit this: // - `let l: lex;` where `lex` struct lives in diff --git a/selfhost/cmd/wcc/check.ww b/selfhost/cmd/wcc/check.ww index 9cb23d6f..747d24f7 100644 --- a/selfhost/cmd/wcc/check.ww +++ b/selfhost/cmd/wcc/check.ww @@ -537,7 +537,16 @@ fn resolvealias(c: *checker, n: *node) *node = { leaf.len = nm.len - dotidx - 1; s = scopelookupinmodule(c.cur, head, leaf); } else { - s = scopelookup(c.cur, nm); + // #53: same-module preference. Mirrors cstage + // cmd/wcc/check.c:66 scope_lookup_prefer. Without this, + // two modules each declaring `type invalid = ...` collide + // on the head-first bucket walk: e.g. utf8.invalid `!void` + // vs strconv.invalid `!i32` resolves to whichever + // registered first, driving localloadop MOVSXD/MOVQ + // divergence at 994/995. Other bare-leaf callers in this + // file (L1597 exprtype N_IDENT, L1795/L2720 N_DOT-callee + // leaf, L600 varianterr, L647 scruttype) tracked as #55. + s = scopelookupprefer(c.cur, c.curmod, nm); // #61 A.5: bare TNAME that collides with an imported // module bareword. Two shapes hit this: // - `let l: lex;` where `lex` struct lives in diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index 87dcf619..35091826 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -7607,7 +7607,16 @@ fn resolvealias(c: *checker, n: *node) *node = { leaf.len = nm.len - dotidx - 1; s = scopelookupinmodule(c.cur, head, leaf); } else { - s = scopelookup(c.cur, nm); + // #53: same-module preference. Mirrors cstage + // cmd/wcc/check.c:66 scope_lookup_prefer. Without this, + // two modules each declaring `type invalid = ...` collide + // on the head-first bucket walk: e.g. utf8.invalid `!void` + // vs strconv.invalid `!i32` resolves to whichever + // registered first, driving localloadop MOVSXD/MOVQ + // divergence at 994/995. Other bare-leaf callers in this + // file (L1597 exprtype N_IDENT, L1795/L2720 N_DOT-callee + // leaf, L600 varianterr, L647 scruttype) tracked as #55. + s = scopelookupprefer(c.cur, c.curmod, nm); // #61 A.5: bare TNAME that collides with an imported // module bareword. Two shapes hit this: // - `let l: lex;` where `lex` struct lives in