Skip to content

Fix deleting unused bindings with Haddock docs V2#4965

Draft
xsebek wants to merge 2 commits into
haskell:masterfrom
xsebek:task/xsebek/fix-4876-delete-unused-haddock
Draft

Fix deleting unused bindings with Haddock docs V2#4965
xsebek wants to merge 2 commits into
haskell:masterfrom
xsebek:task/xsebek/fix-4876-delete-unused-haddock

Conversation

@xsebek

@xsebek xsebek commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@xsebek xsebek force-pushed the task/xsebek/fix-4876-delete-unused-haddock branch from cc86bc7 to 16483df Compare June 13, 2026 21:14
xsebek added 2 commits June 14, 2026 22:24
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
@xsebek xsebek force-pushed the task/xsebek/fix-4876-delete-unused-haddock branch from 9ac310a to 784c49c Compare June 14, 2026 20:31
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"

@xsebek xsebek Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fendor There are a two problems with this:

  1. 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
  2. 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete unused binding code action doesn't delete haddock

1 participant