Fix top level constant resolution#729
Open
vinistock wants to merge 1 commit into04-06-fix_default_parent_classesfrom
Open
Fix top level constant resolution#729vinistock wants to merge 1 commit into04-06-fix_default_parent_classesfrom
vinistock wants to merge 1 commit into04-06-fix_default_parent_classesfrom
Conversation
Member
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
68c9bfb to
d1c948d
Compare
1286e1f to
80710f3
Compare
3bf8916 to
bb9979c
Compare
st0012
approved these changes
Apr 8, 2026
Member
st0012
left a comment
There was a problem hiding this comment.
Can you also update ruby-behaviours doc with this info?
Member
Author
bb9979c to
fbf8915
Compare
80710f3 to
a00812a
Compare
fbf8915 to
9381da4
Compare
a00812a to
1b0feff
Compare
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.

We got the constant resolution algorithm slightly wrong in terms of the top level fallback. This PR fixes it.
Objectis pretty uncommon, but you can see that this is the case because this crashes:And when using constants at the top level of a script, it works because
<main>is an instance ofObject.Object. For example, this works:If Ruby can't find the constant in lexical scopes or ancestors of the surrounding nesting, it searches the ancestors of
Object. The same exact behaviour occurs for top level references like::FOO- even inside classes!