Skip to content
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

Change the meaning of code after correct by Style/RedundantParentheses #2904

Closed
ksss opened this issue Mar 3, 2016 · 5 comments
Closed

Change the meaning of code after correct by Style/RedundantParentheses #2904

ksss opened this issue Mar 3, 2016 · 5 comments

Comments

@ksss
Copy link
Contributor

ksss commented Mar 3, 2016

Expected behavior

class Foo
  def +@
    :+
  end
end
class Fixnum
  def foo
    Foo.new
  end
end

# before correct
+1.foo #=> #<Foo>
+(1.foo) #=> :+

# after correct
+1.foo #=> #<Foo>
+(1.foo) #=> :+

Actual behavior

# snip...
# before correct
+1.foo #=> #<Foo>
+(1.foo) #=> :+

# after correct
+1.foo #=> #<Foo>
+1.foo #=> #<Foo>

RuboCop version

Include the output of rubocop -V:

$ rubocop -V
0.37.2 (using Parser 2.3.0.6, running on ruby 2.4.0 x86_64-darwin15)
@alexdowad
Copy link
Contributor

Looks like things have changed in 2.4.0!

@alexdowad
Copy link
Contributor

I haven't looked at the MRI commit history to find where this change was introduced, but in the absence of further information, it appears more like a bug in Ruby 2.4.0 than anything else.

@jonas054
Copy link
Collaborator

I get the same result with all ruby versions I've tried. +1.foo and +(1.foo) are not equivalent. I think it's a bug to auto-correct the latter into the former.

@alexdowad
Copy link
Contributor

Thanks for pointing this out, @jonas054. I was wrong.

@alexdowad
Copy link
Contributor

I've got a fix, will open a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants