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

Wrap YJIT guard clause in parentheses #51572

Merged
merged 1 commit into from Apr 16, 2024
Merged

Conversation

Bodacious
Copy link
Contributor

@Bodacious Bodacious commented Apr 15, 2024

Motivation / Background

This Pull Request has been created because we encountered a non-obvious bug in the YJIT initializer as defined in the template. To be clear, the bug was caused by changing the code—not the default itself, but it wasn't immediately obvious what was causing it.

Basically, && is an expression. So defined? RubyVM::YJIT.enable && false #=> "expression".

When expanding on the requirements of this condition, I simply added && my_condition? and broke our application for environments where Ruby wasn't built with YJIT.

I think others might get caught out by this.

Detail

This Pull Request wraps defined?(RubyVM::YJIT.enable) in parentheses to ensure the expression is still parsed as expected when additional conditions are added.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included. (Not sure this is required?)

@rails-bot rails-bot bot added the railties label Apr 15, 2024
@rafaelfranca rafaelfranca merged commit 1428ef9 into rails:main Apr 16, 2024
7 of 8 checks passed
@Bodacious Bodacious deleted the patch-1 branch April 18, 2024 09:21
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.

None yet

2 participants