aiken-lang / aiken

A modern smart contract platform for Cardano
https://aiken-lang.org
Apache License 2.0
454 stars 84 forks source link

Needless parentheses around binop inserted by the formatter, following associativity fix #893

Closed KtorZ closed 5 months ago

KtorZ commented 5 months ago

What Git revision are you using?

d1ba8db889f0dff6d1a12cd4523636749113b566

What operating system are you using, and which version?

Describe what the problem is?

Since we fixed the associativity of && and || binary operator, the formatter is now wrongly inserting extra parentheses to sequences with more than 2 operands. And similarly, it will likely remove parentheses changing the associativity.

So for example:

a || b || c

gets formatted as:

a || (b || c)

which is superfluous because of the right-associativity of || already.

What should be the expected behavior?

Parenthesis should only be added / preserved when they do alter the default associativity of those operators.