aiken-lang / aiken

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

aiken fmt bug #966

Closed waalge closed 3 weeks ago

waalge commented 1 month ago

What Git revision are you using?

aiken v1.0.29-alpha+16fb02e

What operating system are you using, and which version?

nixos

Describe what the problem is?

        expect
          tokens.init_tokens() == mint
            |> value.from_minted_value
            |> value.tokens(own_hash)

is "corrected" to

        expect
          ( tokens.init_tokens() == mint )
            |> value.from_minted_value
            |> value.tokens(own_hash)

What should be the expected behavior?

The only reasonable correction

        expect
          tokens.init_tokens() == ( mint 
            |> value.from_minted_value
            |> value.tokens(own_hash))

but , see previous issues, this should also just be default precedence.

Regardless, the correction should type error, since its bool |> value.from_minted_value

KtorZ commented 3 weeks ago

No. There's no issue with the precedence here. The pipe has the lowest precedence of all operators, which is what we want in a FP-oriented language.

waalge commented 3 weeks ago

Precedence issue aside, it is a bug that the formatter should "correct" this rather than flag than ambiguous syntax