Fall back to standard case/when for out-of-int-range Fixnum literals (#9320)#9435
Merged
headius merged 1 commit intoMay 12, 2026
Merged
Conversation
…ruby#9320) The gatherLiteralWhenBodies threw an error(NotCompilableException) when the number was too big for a Java integer. Fixed to do this check before going into the optimized path and taking the default path in case we have a fixnum that is too big or small.
Member
|
Ahh good catch! |
headius
requested changes
May 11, 2026
headius
left a comment
Member
There was a problem hiding this comment.
One minor change and this can merge.
|
|
||
| T expr = (T) whenNode.getExpressionNodes(); | ||
| long exprLong = caseFunction.apply(expr); | ||
| if (exprLong > java.lang.Integer.MAX_VALUE) throw notCompilable("optimized case has long-ranged value", caseNode); |
Member
There was a problem hiding this comment.
Probably should also confirm MIN_VALUE range for consistency.
Suggested change
| if (exprLong > java.lang.Integer.MAX_VALUE) throw notCompilable("optimized case has long-ranged value", caseNode); | |
| if (exprLong > java.lang.Integer.MAX_VALUE || exprLong < java.lang.Integer.MIN_VALUE) { | |
| throw notCompilable("optimized case has long-ranged value", caseNode); | |
| } |
Contributor
Author
There was a problem hiding this comment.
There is a MIN_VALUE range check here.
I removed the throw from here because it's now being checked before we get to buildOptimizedCaseWhen.
headius
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The gatherLiteralWhenBodies threw an error(NotCompilableException) when the number was too big for a Java integer. Fixed to do this check before going into the optimized path and taking the default path in case we have a fixnum that is too big or small.
Specs added here: ruby/spec#1357. (I will write a regression spec if they are not accepted)
Fixes #9320