-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case with complex when uses == instead of === #4804
Comments
Weird. We don't do anything special for different types of objects in case/when (other than static cases like all integers) so I'm not sure why this would be. Shouldn't be hard to fix though. |
Ahh I hadn't noticed the failing version is a little unusual. So I suspect this is because when we can't see a direct value for the |
The IR in both cases appears to be identical. So it's something inside the eqq instruction, most likely. Note in my example eqeqeq is defined as a call rather than a local variable, but it shouldn't matter to IR.
|
Oops, I should have paid closer attention to your report. I just realized you reported against 9.1.9.0 and 9.1.7.0, and indeed both versions do use However, it seems only JRuby master, which will become JRuby 9.2, has fixed this. @enebo Maybe this can be backported, but I'm also not sure if we're doing another 9.1.x. |
If it's fixed on master, then that's good. For my use case, I found a workaround using Up to you if you still want to backport. Thank you Edit: Just tested, i confirm things are working fine on jruby-head. Sorry, I didn't think to check against it. |
@MaxLap Ok no problem. In the absence of anyone else with a serious concern, I'll call this fixed in 9.2 and we'll have it out in the next couple months. |
@headius yeah I think we should backport it unless it is tied to something 2.4 specific. Can I see the commit easily by hitting that helper? |
@enebo I assume it would be something in the compiler, since the IR is different. |
Reopening to backport to 9.1.14. |
@MaxLap Hey a small request: could you try to turn this into a spec for https://github.com/ruby/spec? I realized I never added a test for it, but that would be a good way for you to contribute. I've got a backport in process so this will be fixed in the next 9.1 release. |
@headius Rubyspec updated: ruby/spec@fa47230 |
Thank you @marcandre |
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:
Expected Behavior
output:
Since
(3;eqeqeq)
returns theeqeqeq
, both cases should end up comparing against theeqeqeq
using the===
operator that case should use. So'test'
should be printed twice (with between in-between).Actual Behavior
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:
The text was updated successfully, but these errors were encountered: