-
-
Notifications
You must be signed in to change notification settings - Fork 939
Cannot run code that has large Integer in when clause #9320
Copy link
Copy link
Open
Description
Compiling ruby code that has large Integer in when clause raises org.jruby.compiler.NotCompilableException: optimized case has long-ranged value
case a
when 10000000000
endInteger range that fail to compile is 0x80000000..0x7fffffffffffffff
Environment Information
$ ruby -v
jruby 10.0.4.0 (3.4.5) 2026-03-03 9af05b916f Java HotSpot(TM) 64-Bit Server VM 24.0.2+12-54 on 24.0.2+12-54 +indy +jit [arm64-darwin]
Expected Behavior
No error raised
Actual Behavior
Result
JRuby.compile_ir "case a\nwhen 10000000000\nend"
#=> org.jruby.dist/org.jruby.ir.builder.IRBuilderAST.notCompilable(IRBuilderAST.java:169): optimized case has long-ranged value (CaseNode - :0). (Java::OrgJrubyCompiler::NotCompilableException)$ ruby -e "if false; case 1; when 10000000000; end; end"
Unhandled Java exception: org.jruby.compiler.NotCompilableException: optimized case has long-ranged value (CaseNode - -e:0).
org.jruby.compiler.NotCompilableException: optimized case has long-ranged value (CaseNode - -e:0).
notCompilable at org/jruby/ir/builder/IRBuilderAST.java:169
gatherLiteralWhenBodies at org/jruby/ir/builder/IRBuilderAST.java:1199
buildOptimizedCaseWhen at org/jruby/ir/builder/IRBuilderAST.java:1164
buildCase at org/jruby/ir/builder/IRBuilderAST.java:1055
buildOperand at org/jruby/ir/builder/IRBuilderAST.java:188
build at org/jruby/ir/builder/IRBuilderAST.java:296
build at org/jruby/ir/builder/IRBuilderAST.java:280
build at org/jruby/ir/builder/IRBuilderAST.java:127
buildConditional at org/jruby/ir/builder/IRBuilder.java:1216
buildIf at org/jruby/ir/builder/IRBuilderAST.java:2364
buildOperand at org/jruby/ir/builder/IRBuilderAST.java:218
build at org/jruby/ir/builder/IRBuilderAST.java:296
build at org/jruby/ir/builder/IRBuilderAST.java:280
build at org/jruby/ir/builder/IRBuilderAST.java:158
buildRootInner at org/jruby/ir/builder/IRBuilder.java:276
buildRoot at org/jruby/ir/builder/IRBuilder.java:167
execute at org/jruby/ir/IRTranslator.java:28
runInterpreter at org/jruby/Ruby.java:1242
runInterpreter at org/jruby/Ruby.java:1272
runNormally at org/jruby/Ruby.java:1146
runFromMain at org/jruby/Ruby.java:986
internalRun at org/jruby/main/Main.java:289
run at org/jruby/main/Main.java:239
main at org/jruby/main/Main.java:211This was found in ruby/bigdecimal's ci failure of a draft pull request.
Actual code and workaround:
https://github.com/tompng/bigdecimal/blob/b366afb471c9b2b3c6fc4f5b47634def329895fd/test/bigdecimal/helper.rb#L8-L13
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels