tweag / ormolu

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

Idempotency check fails for comment plus record syntax #936

Open joncol opened 1 year ago

joncol commented 1 year ago

Describe the bug Idempotency check fails for comment plus record syntax.

To Reproduce The simplest piece of code I could come up with that causes the idempotency check to fail:

data X = X { x :: Int }

f = id
    . -- Some comment
    (\s -> s { x = 1 })

Expected behavior Idempotency check should succeed.

Environment Ormolu Live: Version 0.5.0.1, commit [54642a7](https://github.com/tweag/ormolu/commit/54642a7966d1d0787ba84636a2eb52f6729f600e), using ghc-lib-parser 9.4.2.20220822

I'm not sure if this is covered by some already existing bug...?

brandonchinn178 commented 9 months ago

Error output:

<input>
@@ -1,4 +1,9 @@
  f =
    id
-     . (\s -> s {x -- Some comment
-                 = 1})
+     . ( \s ->
+           s
+             { x -- Some comment
+               =
+                 1
+             }
+       )

  Formatting is not idempotent.
  Please, consider reporting the bug.

So primary issue is the comment floating into the lambda