Skip to content

Create TODODeclaration for unresolved constant references #707

@Morriar

Description

@Morriar

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

puts UNRESOLVED

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions