tweag / ormolu

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

Idempotency check fails for comment in import list #1076

Open Vlix opened 8 months ago

Vlix commented 8 months ago

Describe the bug If there is a comment in an (empty) identifier list of an import declaration, the comment floats out (which is already unwanted), but on top of that, in certain situations it's not even idempotent.

To Reproduce The issue in a non-empty identifier list even happens here:

import Package1
import Package3 (
 hi,
 -- , import1
 test,
 )
import Package2

If you change the 2 into a 6, it remains idempotent, so in this case it's the reordering that causes the issue, I think.

The issue within an empty identifier list happens here:

import Package1
import Package3 (
 -- , import1
 )
import Package2

Even if you change the 2 into something >= 4, it's still not idempotent. Removing the 2 though, does work.

Expected behavior The comment should not float out of the identifier list. And the change should be idempotent.

Environment