Shopify / Shopify/rubydex

Create TODODeclaration for unresolved constant references

Open
#707 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
355
Forks
24
Avg merge
2d 6h
Merged PRs (30d)
17

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in resolution.rs at handle_reference_unit() and compare the Outcome::Unresolved(None) path with create_todo_for_parent(). Then inspect the equivalent path in incremental_resolution.rs, along with TodoDeclaration::new() and graph.record_resolved_reference(). Done means unresolved constant references create an appropriately owned TodoDeclaration and are associated in both resolution paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.