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

fix(grainfmt): Remove extraneous parens around infix function application #902

Merged
merged 9 commits into from
Sep 21, 2021

Conversation

marcusroberts
Copy link
Member

Fixes #859

The formatter was cautiously adding parens around too many infix function application parameters.
This has been fixed. The formatter still adds some redundant parens, e.g.

3 + (4 * 5) can be simplified to 3 + 4 * 5

which I will fix in another PR where we take operator precedence into account

@marcusroberts marcusroberts marked this pull request as draft September 19, 2021 18:03
@marcusroberts marcusroberts marked this pull request as ready for review September 19, 2021 19:23
@marcusroberts
Copy link
Member Author

I have much better confidence in this version as I'm using operator precedence and making the comparison in the right place. Quite a few tests too.

Copy link
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! I really love how we write formatter tests.

compiler/grainformat/reformat.re Show resolved Hide resolved
@marcusroberts marcusroberts merged commit 5c1906a into main Sep 21, 2021
@marcusroberts marcusroberts deleted the marcus/extra_parens branch September 21, 2021 20:30
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

Successfully merging this pull request may close these issues.

Formatter: adds redundant parenthesis around expressions
3 participants