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

Invalid code on chained method calls on variables/method with e.g. group name #418

Closed
bquorning opened this issue Mar 9, 2023 · 1 comment

Comments

@bquorning
Copy link
Contributor

  • Ruby version: 2.7.7
  • Rubyfmt git sha: Not sha, but release 0.8.1.

Input file

group(:foo).bar
group.(:foo).bar
group.foo(:bar).baz

Rubyfmt's output

group :foo.bar
group. :foo.bar
group.foo :bar.baz

This breaks because

I don’t think rubyfmt should have changed my source code. I understand (from #358) that the parentheses were removed because it looks better in Bundler’s gemfiles, but when I use group as a variable name, invalid code is produced. (The same problem happens if instead of group I use it, describe, gem, source, or ruby.)

A possible solution (with me having very little knowledge about rubyfmt’s internals) would be to check whether there are any method calls following the end-parenthesis before deciding whether it should be removed or not?

@reese
Copy link
Collaborator

reese commented Mar 11, 2023

Closing this as a duplicate of #414, which has the same root cause, and both of these issues should be resolved by #415

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

2 participants