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

Layout/FirstMethodArgumentLineBreak errors out passing hash in super with brackets #8446

Closed
AirWick219 opened this issue Aug 3, 2020 · 4 comments

Comments

@AirWick219
Copy link
Contributor

Layout/FirstMethodArgumentLineBreak cop errors out while inspecting this line.

def initialize(fruits:)
  super( fruits: fruits ) <--- "An error occurred while Layout/FirstMethodArgumentLineBreak cop was inspecting "
end

But it works if I do this

def initialize(fruits:)
  super({ fruits: fruits })
end

Expected behavior

No error

Actual behavior

1 error occurred:
An error occurred while Layout/FirstMethodArgumentLineBreak cop was inspecting

Steps to reproduce the problem

Add the above line in a method that with the hash key without the bracket.

RuboCop version

0.88.0 (using Parser 2.7.1.4, rubocop-ast 0.3.0, running on ruby 2.6.5 x86_64-darwin19)
@koic koic added the duplicate label Aug 3, 2020
@koic
Copy link
Member

koic commented Aug 3, 2020

This issue is a dup with #8444 and resolved by #8445. Thank you.

@koic koic closed this as completed Aug 3, 2020
@AirWick219
Copy link
Contributor Author

@koic Thanks a lot for the heads up. I am curious about what happened. The only thing changed in the bundle was rubocop-ast updated from 0.1.0 -> 0.3.0 and looking the CHANGELOG.md it doesn't seem like anything might have caused it.

@AirWick219
Copy link
Contributor Author

I double checked rubocop-ast 0.2.0 and it works. Seems like this issue was introduced in rubocop-ast 0.3.0

@marcandre
Copy link
Contributor

marcandre commented Aug 4, 2020

@koic Thanks a lot for the heads up. I am curious about what happened. The only thing changed in the bundle was rubocop-ast updated from 0.1.0 -> 0.3.0 and looking the CHANGELOG.md it doesn't seem like anything might have caused it.

That's my fault, sorry about that. This is due to an optimization I did, but didn't think about possible consequences which is that result of arguments is now sometimes frozen. My personal style is of using more and more immutable data and I try to never mutate results from getters, so I didn't think about it...

I'm adding a reference to this in the Changelog now. Maybe arguments should always return a frozen object too...?

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

No branches or pull requests

3 participants