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

We removed too many parentheses #74

Closed
elbrujohalcon opened this issue Feb 5, 2020 · 4 comments · Fixed by #214
Closed

We removed too many parentheses #74

elbrujohalcon opened this issue Feb 5, 2020 · 4 comments · Fixed by #214
Assignees
Labels
bug Something isn't working started
Milestone

Comments

@elbrujohalcon
Copy link
Collaborator

elbrujohalcon commented Feb 5, 2020

The formatter currently formats…

-define(Now(), 100).
-define(Elapsed(Since), (?Now() - Since)).
-define(Remains(Since, Remaining), N - ?Elapsed(Since)).

…as…

-define(Now(), 100).
-define(Elapsed(Since), ?Now() - Since).
-define(Remains(Since, N), N - ?Elapsed(Since)).

…which is, of course, wrong.

The result of ?Remains(1, 200) should be 200 - (100 - 1) = 101 and not 200 - 100 - 1 = 99.

@elbrujohalcon
Copy link
Collaborator Author

This issue can't be solved until we have a fix for inaka/katana-code#40.

@elbrujohalcon elbrujohalcon removed this from the 0.3.0 milestone Apr 27, 2020
@elbrujohalcon elbrujohalcon added this to the After Improving ktn_code milestone May 6, 2020
@elbrujohalcon elbrujohalcon modified the milestones: After Improving ktn_code, 0.7.1 Nov 19, 2020
elbrujohalcon added a commit that referenced this issue Nov 19, 2020
elbrujohalcon added a commit that referenced this issue Nov 19, 2020
elbrujohalcon added a commit that referenced this issue Nov 19, 2020
elbrujohalcon pushed a commit that referenced this issue Nov 19, 2020
* [#74] Fix #74 by upgrading katana-code

* [#74] Fix test
@michalmuskala
Copy link

michalmuskala commented Nov 19, 2020

This is also problematic with parentheses used in macro calls, not only definitions. Does rebar3_format preserve them now?

e.g.

-define(MUL(A, B), A * B).

?MUL((1 + 2), (3 + 4)).

With parens in the call it's 21, without it's 11

@elbrujohalcon
Copy link
Collaborator Author

Good catch, @michalmuskala!

And… of course rebar3_format doesn't preserve them… 🤦

@elbrujohalcon
Copy link
Collaborator Author

Man… I hate macros so much!
To be fair… I hated them way before working on the formatter… even before working on a linter…

old man yells at cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working started
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants