You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Imported type name shadows a same-named local in value/receiver position (should be a value-namespace lookup) #628
When a module imports a type whose name matches a local/param, the local is shadowed in VALUE position. Minimal repro (needs any module exporting type code):
use std.zlib // exports an internal type 'code'
fn describe(code: str) -> i64:
code.len() // error: unknown method 'len' for type 'code'
The receiver code resolves to the TYPE before the local str param. This makes any common type name exported by any std module (code, state, node, result, …) a footgun for consumers.
Spec
Rust/most languages keep type and value namespaces separate; §-wise this is ergonomics (a local must win for a value expression). Discovered while working #623 (the immediate blocker was worked around by renaming zlib's internal code→zhuff, but the resolver bug is the general fix).
Fix direction
In method-call / value-position identifier resolution, consult scope (locals/params) BEFORE type names. Candidate: the receiver-classification path in SemaCheck (where an NK_IDENT receiver becomes a static-type receiver).
Fixed in 7756348; build + fixpoint + full test suite green (GATES EXIT: 0). static_receiver_type_is_known now returns 0 for a bare identifier that resolves to a bound local/param, so it is an instance receiver rather than a static type reference. Verified: code.len() (param code: str + local/imported type code) returns 5; static calls (Vec.new(), Point.origin()) still resolve. Fixture: test/behavior/behav_local_shadows_type_name.w.
Activity
ehartford commentedon Jul 4, 2026
Fixed in 7756348; build + fixpoint + full test suite green (GATES EXIT: 0).
static_receiver_type_is_knownnow returns 0 for a bare identifier that resolves to a bound local/param, so it is an instance receiver rather than a static type reference. Verified:code.len()(paramcode: str+ local/imported typecode) returns 5; static calls (Vec.new(),Point.origin()) still resolve. Fixture:test/behavior/behav_local_shadows_type_name.w.Fix #628: a bound local wins over a same-named type in receiver position