tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
938 stars 83 forks source link

Ormolu incorrectly inserts parentheses around type-level multiplication #1109

Closed isovector closed 2 months ago

isovector commented 2 months ago

Describe the bug

Ormolu formats the following

{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE NoStarIsType #-}

import GHC.TypeLits

test :: Blah (x * y) -> z

as:

{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE NoStarIsType #-}

import GHC.TypeLits

test :: Blah (x (*) y) -> z

which causes a kind error.

To Reproduce As above

Expected behavior As above

Environment Occurs online:

Version 0.7.4.0, commit 6079787, using ghc-lib-parser 9.8.1.20231009

amesgen commented 2 months ago

Huh, I can't reproduce this, neither on Ormolu Live nor with Ormolu 0.7.4.0 CLI :thinking:

isovector commented 2 months ago

Oh weird, neither can I now. I added the NoStarIsType after the fact, and that seems to be the fix here. The place I originally ran into this in a real codebase which has NoStarIsType enabled globally, but there I get the reported behavior.

Let me look into another repro. Sorry for the confusion.

isovector commented 2 months ago

Explicitly adding NoStarIsType to my module is confirmed to fix the problem. I don't know why it's not getting picked up from the cabal file, but that's good enough for me. Thanks!

amesgen commented 2 months ago

No problem! Feel free to reopen or open another issue in case you find a reproducer for NoStarIsType not getting picked up from the cabal file. (Just tried the simplest possible example, and it works at least there.)