-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idempotence bug involving moving comments #340
Comments
This is actually pretty strange. My mental model is that in all cases the comment should be attached to |
Here is a smaller version: foo reply -- XXX
= foo What happens is that when we are deciding whether a comment follows an element, one of the predicates we use is Similar issues also occur on almost everywhere we move something to a line above. Some examples I made up: foo = \case
True -- foo
-> False
False -> True foo
:: () -- bar
= foo a = b $ -- foo
do
foo foo =
let a -- foo
= b
in c Everything above has idempotence issues. I couldn't figure out an easy solution. Only thing I can come up with is adding a flag to the |
I do not understand is why One thing seems to be clear: while the current approach works decently in most cases, there are many marginal situations where it fails and from what I've seen and investigated, the idempotence issues we're facing right now are not at all easy to fix. Perhaps a completely different approach to comment rendering is necessary here. |
OK, more precisely it is not ormolu/src/Ormolu/Printer/Comments.hs Line 204 in 5c923a2
We cannot return At least it's clear now what exactly is going on here. |
From formatting
parsec3
:Original input:
1 pass:
2 pass (fixpoint):
The text was updated successfully, but these errors were encountered: