Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix defined? to not call const_missing #2309

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

richardboehme
Copy link
Contributor

This fixes defined? to not call const_missing if it was implemented, so that missing constants actually return nil.

Additionally this fixes conditional constant write operations, because those relied on the behavior of defined?.

I also upstreamed the test from natalie/defined_test.rb to ruby/spec#1215

This was previously broken because we used a defined instruction that
was calling `const_missing` and thus did not set the constant.

We now use the new `ConstLookupFailureMode::Raise` to ensure that the
lookup for the constant raises which in turn leads to the constant
being assigned correctly.
@richardboehme richardboehme merged commit af62600 into master Nov 8, 2024
15 checks passed
@richardboehme richardboehme deleted the rb/defined-const-missing branch November 8, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants