Skip to content

Don't include Object for pathed constant searches#8912

Merged
headius merged 2 commits intojruby:jruby-9.4from
headius:const_defined_no_object
Jul 12, 2025
Merged

Don't include Object for pathed constant searches#8912
headius merged 2 commits intojruby:jruby-9.4from
headius:const_defined_no_object

Conversation

@headius
Copy link
Member

@headius headius commented Jul 12, 2025

The fix here is a little bit form-fitting but largely avoids inheriting constants from Object when doing String-based constant lookups and skips the additional search of Object if we are doing a path search.

@headius headius force-pushed the const_defined_no_object branch 5 times, most recently from 5128229 to c636075 Compare July 12, 2025 21:40
headius added 2 commits July 12, 2025 18:00
The change here is form-fit to this specific case, but basically,
we never search Object as an inherited namespace for const_defined?
and if we are doing a namespaced lookup don't do the extra search
against Object either.

Other paths like const_get should continue to search Object to fit
the spec.

Fixes jruby#8867
@headius headius force-pushed the const_defined_no_object branch from c636075 to cb9143c Compare July 12, 2025 23:00
@headius headius marked this pull request as ready for review July 12, 2025 23:13
@headius headius linked an issue Jul 12, 2025 that may be closed by this pull request
@headius headius added the core label Jul 12, 2025
@headius headius changed the title Only include Object in search if starting from root Don't include Object for pathed constant searches Jul 12, 2025
@headius headius merged commit 8828f3a into jruby:jruby-9.4 Jul 12, 2025
97 checks passed
@headius headius deleted the const_defined_no_object branch July 12, 2025 23:25
@headius
Copy link
Member Author

headius commented Jul 12, 2025

I did this fix against 9.4 but it will be released in 10.0.1.0 first. Stupid github still doesn't allow multiple milestones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object.const_defined? not respecting namespace check.

1 participant