ormolu icon indicating copy to clipboard operation
ormolu copied to clipboard

Not idempotent with comment in let-block

Open brandon-leapyear opened this issue 3 years ago • 0 comments

Describe the bug The following source code will be reformatted twice:

foo :: IO ()
foo = let
  foo' = do
    putStrLn "hi"
  -- test
  in foo' >> putStrLn "bye"

To Reproduce Run ormolu the first time gets

 foo :: IO ()
-foo =
-  let foo' = do
-       putStrLn "hi"
-       -- test
-  in foo' >> putStrLn "bye"
+foo = let
+  foo' = do
+    putStrLn "hi"
+  -- test
+  in foo' >> putStrLn "bye"

Run ormolu again rewrites it again to:

 foo :: IO ()
 foo =
   let foo' = do
         putStrLn "hi"
-  -- test
-  in foo' >> putStrLn "bye"
+  in -- test
+     foo' >> putStrLn "bye"

Any future runs of ormolu will not make any changes

Expected behavior Should go from the original to the last change directly

Environment

  • OS name + version: Mac
  • Version of the code: master at 34bdf62

Additional context Add any other context about the problem here.

brandon-leapyear avatar Mar 04 '21 20:03 brandon-leapyear