ormolu icon indicating copy to clipboard operation
ormolu copied to clipboard

Idempotency check fails for comment plus record syntax

Open joncol opened this issue 1 year ago • 1 comments

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

  • Version of the code: See above.

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

joncol avatar Nov 10 '22 07:11 joncol

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

brandonchinn178 avatar Jan 22 '24 06:01 brandonchinn178