Wrap YJIT guard clause in parentheses #51572
Merged
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.
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. Sodefined? 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:
[Fix #issue-number]
Tests are added or updated if you fix a bug or add a feature.