tweag / ormolu

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

AST differs on comment in line before `$` in a `do` block #1028

Open amesgen opened 1 year ago

amesgen commented 1 year ago

Describe the bug Formatting this code with --unsafe

foo = do
  bar
    -- txt
    $ baz

yields

foo = do
  bar
  -- txt
  $
    baz

which has differing AST: The LHS of $ is now the entire do block.

Expected behavior It should be formatted correctly, e.g. with output

foo = do
  bar $
    -- txt
    baz

The same thing happens for all infixr 0 (isHardSplitterOp) operators.

Environment

Additional context This is not reproducible on the current Ormolu Live; but this is completely unrelated, will open a PR (EDIT: #1029) for that soon. Now fixed.