Fix deleting unused bindings with Haddock docs V2#4965
Draft
xsebek wants to merge 2 commits into
Draft
Conversation
cc86bc7 to
16483df
Compare
Co-authored-by: kunduagam23@gmail.com
* Tweak unused binding test * Refactor findRelatedSigSpan to avoid inner let * Use epaLocationRealSrcSpan * Revert unused annotated type * Fixup for GHC 9.10 * Just give up for GHC=<9.8 * Add comments
9ac310a to
784c49c
Compare
xsebek
commented
Jun 14, 2026
Comment on lines
+2536
to
+2543
| , testSession "delete unused top level binding with Haddock comment" $ | ||
| testFor | ||
| [ "{-# OPTIONS_GHC -Wunused-top-binds #-}" | ||
| , "module A (some) where" | ||
| , "" | ||
| , "-- | line docs for f" | ||
| , "f :: Int" | ||
| -- TODO: , "-- ^ trailing docs for f" |
Contributor
Author
There was a problem hiding this comment.
@fendor There are a two problems with this:
- The GHC AST changed a lot in 9.10 and the types do not match. It would mean writing the code that finds comments again. Should I dive into type families, or disable (how?) this test for GHC 9.6/.8?
- Apply.Refact.Compat could help, but that does not in turn work on 9.10
- Trailing Haddocks might not be in the same place after GHC does the parsing, the test would not pass. Maybe it's connected to this note about GHC parser only adding "prior comments":
https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/Parser/Annotation.hs?ref_type=heads#L406-413- Trailing style for function declaration seems niche to me, I only used it on record fields. Is this worth fixing, or is there maybe some better example?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
L EpAnn SigD, not on the definitionValD