Problem
When we encounter a constant reference to an unknown constant (e.g. puts UNRESOLVED), the reference remains unlinked — it doesn't get associated with any declaration.
Currently in resolution.rs, the Outcome::Unresolved(None) case for references is essentially a no-op:
Outcome::Unresolved(None) => {
// We couldn't resolve this name. Emit a diagnostic
}
This means the reference is silently dropped with no way to navigate to or from it.
Proposal
When a constant reference cannot be resolved, create a TodoDeclaration for the unresolved constant and associate the reference with it. This is consistent with how we already handle unknown parent namespaces in class/module definitions (see create_todo_for_parent()).
Benefits
- Proper association: The constant reference gets linked to a declaration, making it queryable
- Consistency: Follows the same pattern we already use for unresolved parent namespaces
- Future resolution: If the constant is defined later (e.g. in another file), the Todo can be promoted to a real declaration and all references are already wired up
- Tooling support: Enables "find references" for constants that may be defined outside the currently indexed scope
Example
Today: the reference to UNRESOLVED is unlinked.
Proposed: a TodoDeclaration for UNRESOLVED is created and the reference is recorded against it.
Implementation Notes
- The change would go in
handle_reference_unit() in resolution.rs (and the incremental equivalent)
- We already have
TodoDeclaration::new() and graph.record_resolved_reference() available
- Need to decide on the owner for the Todo (likely the enclosing scope or
Object)
- Should also apply to the incremental resolution path in
incremental_resolution.rs
Problem
When we encounter a constant reference to an unknown constant (e.g.
puts UNRESOLVED), the reference remains unlinked — it doesn't get associated with any declaration.Currently in
resolution.rs, theOutcome::Unresolved(None)case for references is essentially a no-op:This means the reference is silently dropped with no way to navigate to or from it.
Proposal
When a constant reference cannot be resolved, create a
TodoDeclarationfor the unresolved constant and associate the reference with it. This is consistent with how we already handle unknown parent namespaces in class/module definitions (seecreate_todo_for_parent()).Benefits
Example
Today: the reference to
UNRESOLVEDis unlinked.Proposed: a
TodoDeclarationforUNRESOLVEDis created and the reference is recorded against it.Implementation Notes
handle_reference_unit()inresolution.rs(and the incremental equivalent)TodoDeclaration::new()andgraph.record_resolved_reference()availableObject)incremental_resolution.rs