fix: allow lexical import shadowing

This commit is contained in:
2026-08-22 17:53:31 +09:00
parent 89f519d5cb
commit 6279d46652
19 changed files with 1420 additions and 270 deletions

View File

@@ -3642,13 +3642,16 @@ fn cgdot(c: *cgen, n: *syntax.node) void = {
// → inline the pre-computed constant. `pkg.Enum.MEMBER` keeps
// `pkg` so enumlookupmod can prefer the explicit module on a
// leaf collision; bare `Enum.MEMBER` falls back to c.curmod via
// enumlookup's same-module-first walk.
// enumlookup's same-module-first walk. A live local with the same
// spelling wins before this name-only registry fallback; valid local
// enum selectors were already folded by the checker.
if (lhs != nil) {
let etname: str;
let etmod: str;
etname.ptr = nil; etname.len = 0;
etmod.ptr = nil; etmod.len = 0;
if (lhs.kind == syntax.nkind.N_IDENT) {
if (lhs.kind == syntax.nkind.N_IDENT
&& localfindnode(c, lhs.str) == nil) {
etname = lhs.str;
};
if (lhs.kind == syntax.nkind.N_DOT) {