Create TODO declarations for unresolved parent scopes#529
Merged
Conversation
vinistock
reviewed
Jan 28, 2026
efe1f7f to
ab4b06a
Compare
vinistock
reviewed
Mar 4, 2026
1b010c4 to
e0f2509
Compare
vinistock
approved these changes
Mar 4, 2026
When resolving `class Bar::Baz` inside `module Foo`, if `Bar` can't be found, the previous code used lexical nesting to create a Todo named `"Foo::Bar"`. This was wrong: since `Bar` has no explicit `::` prefix, the placeholder should live at the top level as `"Bar"`, so it can be promoted when `module Bar` is later discovered. Fix: in the Unresolved(None) arm of name_owner_id, check whether the failing scope has an explicit `::` prefix. If not (bare name), use OBJECT_ID directly instead of recursing through nesting. For qualified names like `Outer::Inner` the recursive call is still correct. The existing Todo promotion mechanism in add_declaration handles the rest: when `module Bar` is processed (same or next resolve_all), the Todo at `"Bar"` is promoted and its members transferred.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consider this:
Without this PR, if
Foocan't be resolved,Barnever gets created andbar()ends up underObject.This PR introduces
TodoDeclaration, a placeholder namespace used when a parent scope can't be resolved. Rather than running the resolution queue twice (once normally, then again in a "create Todos" mode), we create Todos eagerly in a single pass by leveraging the existing constant → namespace promotion mechanism from #505.The logic for the example above now looks like this:
If a real
class Fooormodule Foodefinition appears later,Foois promoted fromTodotoClass/Modulein place — same mechanism used to promote constants to namespaces.Unresolved outcomes with a pending linearization (
Unresolved(Some(id))) are propagated as-is rather than triggering Todo creation, so we don't create premature Todos for names that might resolve once ancestor chains are fully computed.