Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
jRuby 9050 and 9100 behave differently for case / when with Array from MRI #3897
The following code returns different results between jRuby and MRI.
ALL = ['v0', 'v1'] vs = ['v0', 'v1'] case vs when ALL then 1234 else raise 'Undefined' end
RuntimeError: Undefined from (irb):7:in `<eval>' from org/jruby/RubyKernel.java:983:in `eval' from org/jruby/RubyKernel.java:1290:in `loop' from org/jruby/RubyKernel.java:1103:in `catch' from org/jruby/RubyKernel.java:1103:in `catch' from /Users/yjun/.rvm/rubies/jruby-126.96.36.199/bin/irb:13:in `<top>'
Another code using if / else:
ALL = ['v0', 'v1'] vs = ['v0', 'v1'] if ALL === vs 1234 else raise 'Undefined' end
=> This code returns the same result ( 1234: good ).
Is this a known issue?
@subbuss I think the problem is that the IR does not distinguish between these two whens:
ary = [1,2,3] case x when 1,2,3 # 1, 2, 3 should each be used to === in turn when ary # Array#== should be called once end
Both cases fall into
rescue may have a similar bug.