Switch symbol mangling from the import leaf clause to the full dotted import path for directory packages; single-file imports keep package-clause mangling (isdir-gate: imported<=>directory-import). The root build unit's fn main stays bare, every other top-level decl mangles, closing #31's duplicate-main hazard by construction (#32). Both stages, byte-identical. Single commit, not split: the bare rename (f244af3) is red on its own because it unmasks cross-module resolution gaps that do not reproduce pre-M1, so the fixes are intrinsic to making the rename correct. Included: wwstage fnret/fnparamslookupmod map import alias->path (#199b cross-module union-variant scrutinee resolved the wrong fn's union); cstage use_path prefers the referencing module's import for an ambiguous leaf alias (sha256 crypto.math vs strconv math). Tests table-driven: 989_m1mangle_run/_sym, 989_m1union_run (gate-visible per-arm exit codes + cs==ww byte-id).
This commit is contained in:
@@ -2167,10 +2167,14 @@ fn structlookup(c: *cgen, name: str) *structinfo = {
|
||||
let leaf: str;
|
||||
leaf.ptr = name.ptr + ((i + 1): u64);
|
||||
leaf.len = name.len - (i + 1);
|
||||
// M1 #22: the embedded qualifier (`utf8`) is the use ALIAS;
|
||||
// the struct's smod is now the dotted import PATH
|
||||
// (`encoding.utf8`). Map alias→path before comparing.
|
||||
let pkgmod: str = usehint(c, pkg);
|
||||
let b: *structinfo = c.structs;
|
||||
for (b != nil) {
|
||||
if (streq(b.sname, leaf)) {
|
||||
if (streq(b.smod, pkg)) {
|
||||
if (streq(b.smod, pkgmod)) {
|
||||
return b;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user