ormolu
ormolu copied to clipboard
Interesting comment placements in various scenarios
Describe the bug
Here are a bunch of strange comment placements that I've noticed.
To Reproduce
Positive example
This one looks good
Input, & Output
example =
[ -- A
[], -- B
-- C
[] -- D
-- E
] -- F
Using QQ in the previous example
Input (& expected output)
example =
[ -- A
[u||], -- B
-- C
[u||] -- D
-- E
] -- F
Output
example =
[ -- A
[u||],
-- B
-- C
[u||]
]
-- D
-- E
-- F
Record with comment on each line
Input (& expected output)
example =
Record
{ -- A
field = (), -- B
-- C
field = (), -- D
-- E
.. -- F
} -- G
Output
example =
Record
{ -- A
field = (), -- B
-- C
field = (), -- D
-- E
..
}
-- F
-- G
Records with fewer comments
Notice how -- E
here is also moved, which differs from the previous example.
Input (& expected output)
example =
Record
{ -- A
field = (),
-- C
field = (),
-- E
.. -- F
} -- G
Output
example =
Record
{ -- A
field = (),
-- C
field = (),
..
}
-- E
-- F
-- G
Environment
- OS name + version: https://ormolu-live.tweag.io/
- Version of the code: 0.7.3
Comment in import lists
It looks like ormolu interprets the comment as relating to the import Example3
line.
Input (& expected output)
import Example1
import Example2 ({- comment -})
import Example3
Output
import Example1
import Example2 ()
{- comment -}
import Example3