Expand description
#1824: where a unit’s own code meets an imported declaration’s position that names a type the unit shadows.
A unit’s own type Repo shadows the Repo of a commons it uses
directly (compose_unit_symbols: local first), and that stays legal:
1697_derived_names_collide declares its own Message beside
uses bynk.locale.types. But type names are bare strings to the checker,
so an imported declaration that names Repo (t.model’s
type Run = { repo: Repo }) is checked here against the local Repo.
Run { repo: 42 } checks, and the emitted TypeScript, typed against
t.core’s Repo, fails tsc.
crate::project_model::close_reachable_types records each such reach
(ShadowedReaches); this pass, run after a file’s bodies are checked,
reports bynk.uses.name_conflict where a value crosses between the unit’s
own code and one of those shadowed positions. A shadowed position is a
position of an imported declaration whose declared type names a shadowed
type, resolved in the declaring unit’s scope:
- a value goes in at a record field (
Run { repo: … }, and the overrides ofRun { ...r, repo: … }), a fn, method or static parameter, or a variant payload (Text(…)); - a value comes out of a field read (
r.repo), a call’s result, or a payload amatcharm oristest binds.
A value that comes out of one shadowed position straight into another
naming the same types never meets the unit’s own code: both sides mean the
imported type, in the checker and in the emitted TypeScript alike. That is
1697’s render(tag, message("greeting")), which stays legal. Every other
crossing is a conflict, including one that goes through a let first:
the rule reads the expression in the position, not where its value came
from, so it errs towards rejecting.
Not covered: a reference to an imported fn as a value (list.map(f)), and
a payload bound by a nested pattern (Some(Text(v))). Test suites are
checked by crate::test_suites, which does not run this pass.
Structs§
- Shadow
Scope - The unit-level tables the pass resolves an imported declaration through.
Functions§
- check_
shadowed_ uses - Report every crossing in
typed’s bodies: fns and methods (with their contracts), service and agent handlers, agent invariants and transitions, and provider operations. Empty when no imported declaration reaches a shadowed type, which is the common case and costs one check.