Commit 188acee
Fix constant resolution to prioritize nesting scope over Object ancestors
In Ruby's constant lookup, lexical scope (nesting) takes priority over
ancestors. However, `resolve` searched all ancestors including Object
before checking outer nesting scopes. This caused `include Store` inside
`ActiveRecord::Base` to resolve to `::Store` (app model, via Object)
instead of `ActiveRecord::Store` (via nesting).
Stop ancestor search at Object when outer nesting scopes remain to be
checked (cref.outer), while preserving existing behavior for
ScopedConstRead which already passes break_object=true.1 parent b93d846 commit 188acee
2 files changed
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments