Visitar URL original
Pass the scope field to refined call sites for splatted when by sferik · Pull Request #9832 · jruby/jruby · GitHub
Skip to content

Pass the scope field to refined call sites for splatted when - #9832

Merged
headius merged 1 commit into
jruby:masterfrom
sferik:jit-refined-eqq
Oct 20, 2026
Merged

headius merged 1 commit into
jruby:masterfrom
sferik:jit-refined-eqq

Conversation

@sferik

@sferik sferik commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #9827.

A splatted when clause, like when *WORDS, compiles to an eqq that goes through invokeEQQ, and invokeEQQ passed null as the scope field name to pushCallSite. That's fine until the call site is potentially refined, which it is in any file or class that calls using. A refined call site loads the static scope from that field to find the active refinements, so the compiler emitted a getstatic with a null name and ASM threw a NullPointerException. The method, and any block containing the case, stayed interpreted.

This passes the method's scope field through, the same way asString already does. That meant adding a parameter to InvocationCompiler#invokeEQQ; the two implementations are the only ones.

The new spec refines String#=== and checks that a splatted when uses it, so it covers both that the method compiles and that the refinement still applies in compiled code. It fails in JIT and AOT mode before this change and passes in all four modes after it, and the result matches CRuby. irb's RegexpCompletor#select_message, which the issue mentions, now compiles too.

invokeEQQ, used for a splatted when clause like when *WORDS, passed
null as the scope field name to pushCallSite. A potentially refined
call site needs that field to find the active refinements, so in a file
or class that calls using, the compiler emitted a getstatic for a null
field name and ASM threw a NullPointerException. The method and its
blocks stayed interpreted.

Pass the method's scope field through, as asString already does.

Fixes jruby#9827

@headius headius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a wonderful world of refinements. Probably my least favorite Ruby feature, although Ruby::Box might take over that title.

This is pretty clearly just a missed compiler path when dealing with refinements. I won't lose any sleep over making refined code run slower, but we might as well fix this anywhere.

Simple fix, looks good.

@headius headius added this to the JRuby 10.1.3.0 milestone Oct 20, 2026
@headius
headius merged commit 90d4b16 into jruby:master Oct 20, 2026
135 checks passed
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.

JIT can't compile when *array in a file that uses refinements (NullPointerException in invokeEQQ)

2 participants