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

@@ -482,6 +482,13 @@ struct Sym {
* Lets resolve_typename treat `foo.x`
* as module-qualified even though the
* primary kind isn't SK_USE. */
const char *mod; /* importing module's bareword for
* symbols originating in a `use`-
* imported module. NULL for primary
* (root) compilation unit symbols.
* Used by scope_lookup_in_module to
* disambiguate same-leaf-name types
* coming from different imports. */
Sym *next; /* iteration */
Sym *hashnext; /* bucket chain */
Scope *scope;
@@ -497,8 +504,11 @@ struct Scope {
Scope *newscope(Arena*, Scope *parent);
Sym *scope_define(Scope*, const char *name, Skind, Type*, Node *decl);
Sym *scope_define_in_module(Scope*, const char *name, const char *mod,
Skind, Type*, Node *decl);
Sym *scope_lookup(Scope*, const char *name); /* walk up parents */
Sym *scope_lookup_local(Scope*, const char *name);
Sym *scope_lookup_in_module(Scope*, const char *mod, const char *name);
/* ---- checker (check.c) -------------------------------------------- */
typedef struct Checker Checker;