Repository navigation
Give string range endpoints the scope's file name - #9838
Merged
Merged
Conversation
buildRange turned a string literal endpoint into a FrozenString with
the StrNode's file name, but Node#getFile always returns null. When
both endpoints were literals the file was never used, but a range like
"a"..x or ("a"..) visits the FrozenString on its own, which passes the
file to invokedynamic as a bootstrap argument, and ASM rejects null.
Those methods couldn't be JIT-compiled.
Use scope.getFile(), as every other FrozenString in the builder does.
Endless and beginless string ranges also go through the AOT fallback in
NormalValueCompiler#pushRange, which called a RubyRange.newRange
overload that doesn't exist. This includes the same fix for that as
jruby#9833, so the two merge cleanly in
either order.
Fixes jruby#9822
headius
approved these changes
Oct 20, 2026
headius
left a comment
Member
There was a problem hiding this comment.
Surprising this didn't come up during the initial implementation. I believe that file is only populated during debug runs, to error or warn about modifying a frozen or chilled string. Getting it from the scope is fine, but we may want to revisit that and populate the file since the field is already there and the filename String object would be the same one.
Simple fix, looks good.
This was referenced Oct 20, 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.
Fixes #9822.
IRBuilder#buildRangeturns a string literal endpoint into aFrozenString, but it took the file name from theStrNode, andNode#getFilealways returnsnull. When both endpoints are literals the file never gets used, so"a".."z"was fine. But with a non-literal endpoint, as in"a"..x, or with an endless or beginless range like("a"..), theFrozenStringgets compiled on its own and passes the file to invokedynamic as a bootstrap argument, which ASM rejects withIllegalArgumentException: value null.This uses
scope.getFile(), which is what every otherFrozenStringin the builder uses.Endless and beginless string ranges also go through the AOT fallback in
NormalValueCompiler#pushRange, which called aRubyRange.newRangeoverload that doesn't exist. That's the same fix as in #9833, and since the change is identical, the two merge cleanly in either order.The new spec covers
"a"..x,x..."e",("a"..)and(.."b"). It fails in JIT and AOT mode before this change and passes in all four modes after it.