Create TODO declarations for unresolved parent scopes#529
Open
Create TODO declarations for unresolved parent scopes#529
Conversation
Instead of passing it around. Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Used to represent namespaces we couldn't resolve but are used as parent scope of another namespace. Consider this: ```rb class Foo::Bar def bar; end end ``` While we can't resolve `Foo`, we want to create `def bar` in the right namespace: `Foo::Bar`. Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
vinistock
reviewed
Jan 28, 2026
| .as_namespace() | ||
| .unwrap() | ||
| .get(nesting_declaration_id)? | ||
| .as_namespace()? |
Member
There was a problem hiding this comment.
Why does this need to change?
| // Once we've processed the queue and create all we could, what's remaining is depending on other unresolved units. | ||
| // We'll create TODO declarations for these and process the queue again to resolve what we can. | ||
| self.create_todo_declarations = true; | ||
| self.process_queue(); |
Member
There was a problem hiding this comment.
Instead of looping through the queue twice, can we not incorporate Todo in the regular processing?
If we eagerly create unresolved definitions as Todo, while still enqueuing a retry, we could do everything in a single loop.
Maybe in combination with #505
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:
Right now, if we can't resolve
Foo, we won't create a definition forBarand will end up creatingbar()under object:Object#bar().With this PR, we try to resolve everything then, for the remaining definition we couldn't resolve, we enter in a mode where we create TODO declaration for the missing ones and try to resolve what it unblocks.
So for our example the logic would look like this: