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

Some cases of assignment in conditional do not warn as in MRI #3757

Closed
headius opened this Issue Mar 24, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@headius
Member

headius commented Mar 24, 2016

Environment

JRuby 9.1 (HEAD)

Expected Behavior

We should display the same warnings for "assignment in conditional" as in MRI.

Actual Behavior

The following cases differ, which prevents MRI's TestRubyOptions#test_assignment_in_conditional from passing. These are the only remaining issues for that test to be green.

Here's output comparing JRuby and MRI:

[] ~/projects/jruby $ jruby -Xbacktrace.style=mri -e "if a = [a]; end"
-e:1: warning: found = in conditional, should be ==

[] ~/projects/jruby $ jruby -Xbacktrace.style=mri -e "if a = {1=>2}; end"

[] ~/projects/jruby $ jruby -Xbacktrace.style=mri -e "if a = {}; end"

[] ~/projects/jruby $ ruby23 -e "if a = [a]; end"

[] ~/projects/jruby $ ruby23 -e "if a = {1=>2}; end"
-e:1: warning: found = in conditional, should be ==

[] ~/projects/jruby $ ruby23 -e "if a = {}; end"
-e:1: warning: found = in conditional, should be ==

@headius headius added the parser label Mar 24, 2016

headius added a commit that referenced this issue Mar 24, 2016

Fix a couple exception messages.
The "assignment" warning fix almost gets MRI's TestRubyoptions#
test_assignment_in_conditional, but there's a few cases where we
differ from MRI in warning output. See #3757.

@enebo enebo closed this in 1a829a7 Apr 1, 2016

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Apr 1, 2016

Member

This involved two fixes:

  1. HashNode was not marked as a ILiteralNode
  2. The warning only triggers if Arrays/Hashes do not contain anything but other literal nodes.
Member

enebo commented Apr 1, 2016

This involved two fixes:

  1. HashNode was not marked as a ILiteralNode
  2. The warning only triggers if Arrays/Hashes do not contain anything but other literal nodes.

@enebo enebo added this to the JRuby 9.1.0.0 milestone Apr 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment