w6c+selfhost: same-module preference for bare-leaf lookup

This commit is contained in:
2026-05-15 11:24:33 +09:00
parent 35b32c1304
commit e6045f3ada
13 changed files with 382 additions and 12 deletions

View File

@@ -509,6 +509,7 @@ Sym *scope_define_in_module(Scope*, const char *name, const char *mod,
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);
Sym *scope_lookup_prefer(Scope*, const char *mod, const char *name);
/* ---- checker (check.c) -------------------------------------------- */
typedef struct Checker Checker;
@@ -517,6 +518,12 @@ struct Checker {
Scope *top; /* file scope */
Scope *cur; /* current scope */
Type *ret; /* expected return type of current fn (or NULL) */
const char *cur_mod; /* importing-module bareword for the decl
* currently being checked; NULL for primary
* compilation unit. Drives same-module
* preference in bare-leaf lookups so a bare
* `read` inside lib/os resolves to os.read
* rather than colliding io.read. */
int loops; /* nesting count for break/continue */
int errs;
};