Shadowed names provide very unhelpful error messages #48

Closed
opened 2026-07-20 11:50:54 +02:00 by st · 0 comments
Owner
Repro of the smell (current behavior):
  use std/Eq
  Eq.eq(3, 3)        # → "error: unbound variable 'Eq.eq'"
`use std/Eq` imports the MODULE Eq, shadowing the prelude's INTERFACE Eq; `eq` isn't a
module member, so it should be a clean resolve error, but resolve emits an optimistic
MemberRef and infer reports it. (Without the `use`, Eq.eq works fine — generalization is
not the issue.)

Root: resolve.mli:1 states "every name reference is classified by its binding category,"
but qualified `Mod.member` violates it. resolve's module namespace is PUBLIC-ONLY
(module_sig_names filters private, types.ml:~241), so resolve can't tell "absent" from
"private" and defers both (ARModule branch resolve.ml:~768-799 → qualified_binding
~691). Infer does the real check at infer.ml:~1438-1445 against the full sig
(module_sig.members keeps visibility). Visibility is SYNTACTIC (pub/private), so giving
resolve visibility does NOT re-couple to inferred sigs — the phase separation is about
inferred TYPES only.
``` Repro of the smell (current behavior): use std/Eq Eq.eq(3, 3) # → "error: unbound variable 'Eq.eq'" `use std/Eq` imports the MODULE Eq, shadowing the prelude's INTERFACE Eq; `eq` isn't a module member, so it should be a clean resolve error, but resolve emits an optimistic MemberRef and infer reports it. (Without the `use`, Eq.eq works fine — generalization is not the issue.) Root: resolve.mli:1 states "every name reference is classified by its binding category," but qualified `Mod.member` violates it. resolve's module namespace is PUBLIC-ONLY (module_sig_names filters private, types.ml:~241), so resolve can't tell "absent" from "private" and defers both (ARModule branch resolve.ml:~768-799 → qualified_binding ~691). Infer does the real check at infer.ml:~1438-1445 against the full sig (module_sig.members keeps visibility). Visibility is SYNTACTIC (pub/private), so giving resolve visibility does NOT re-couple to inferred sigs — the phase separation is about inferred TYPES only. ```
st closed this issue 2026-07-27 09:46:43 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
st/amelie#48
No description provided.