-
Notifications
You must be signed in to change notification settings - Fork 81
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
Backslash escaping of invalid haddock triggers seems excessive #1131
Comments
Thanks for opening this, the situation around invalid Haddock comments certainly is a bit subtle.
That's exactly why they are invalid: GHC has the
That's exactly why these two markers are escaped, Ormolu just reuses the GHC logic here. Your specific use case with bullet points can be fixed by adding an additional space before the |
I see, thanks. But "at the start of lines in the middle of a multiline comment" doesn't generate a warning, right? That is, {-
*
|
-} gets backslashes added, but there's no warning if they're omitted. |
Oh right, I overlooked that. We sometimes escape Haddock-like triggers even if sth is not an invalid Haddock comment: ormolu/src/Ormolu/Parser/CommentStream.hs Line 142 in 392b2bc
Removing this causes test failures, so this was added for a reason, but I would need to dive into the details again to understand why exactly. Maybe this logic could be made less aggressive, such that this snippet is an Ormolu fixpoint. |
Hm. I'm not familiar with the codebase or tests, but when I remove the |
Two examples where I hit this. Workaround: add leading spaces (#1018 (comment)) Bullets
goes to
Carets
goes to
|
Describe the bug
In #837 (following #816), backslashes were added to comments that start with haddock triggers (
|^$*
), where a haddock trigger isn't allowed.Um, I confess I don't fully understand why. I hear that haddock and/or GHC sometimes has problems when there's a haddock comment somewhere unexpected, but I haven't been able to run into them myself. Is that still an issue with recent GHCs? (I'm actually only using 9.2.) But in any case, reading the issue, it sounds like that's not actually the problem it was intended to resolve?
But regardless of why, it looks to me like this is done unnecessarily in some cases. In particular, it's done at the start of lines in the middle of a multiline comment, where I believe haddock won't pick them up.
As far as I can tell, the current behavior is:
-- |
at the end of the file, which I think is forbidden.)Some of this behavior confuses me, and if possible I'd like to be able to have comments starting with
-- *
in the middle of a function. (I like bullet points, and I'm not sure if haddock cares about those.) The final point is the one that seems most straightforwardly a bug to me.To Reproduce
Input:
Output:
Expected behavior
I think I'd expect this output instead:
Environment
Tested on the web version at https://ormolu-live.tweag.io/. Currently Version 0.7.7.0, commit 392b2bc, using ghc-lib-parser 9.10.1.20240511.
The text was updated successfully, but these errors were encountered: