-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
Environment
jruby 9.1.9.0 and jruby 9.1.7.0
Using mode 1.9, didn't test with others.
Ubuntu 16.04
Linux max-u1604 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
In irb, or in a file, put the following:
class EqEqEq
def ===(other); puts 'test'; end
def ==(other); puts 'test2'; end
end
eqeqeq = EqEqEq.new
case 1; when eqeqeq; end
puts 'between'
case 1; when (3;eqeqeq); end
Expected Behavior
output:
test
between
test
Since (3;eqeqeq) returns the eqeqeq, both cases should end up comparing against the eqeqeq using the === operator that case should use. So 'test' should be printed twice (with between in-between).
Actual Behavior
test
between
test2
So in the second case, == is called instead of ===.
More details
I'm working on something that generates code, and a more complex version of this happens. I managed to reduce the issue to this simple case. This work as expected in MRI.
Another different example of the issue:
case 'a'; when /a/; puts 'hi1'; end #=> prints
case 'a'; when (1;/a/); puts 'hi2'; end
case 'a'; when (1;'a'); puts 'hi3'; end #=> prints
Reactions are currently unavailable