Skip to content

GHC loses Haddock comments on `where`-local declarations

Summary

GHC loses Haddock comments on where-local declarations.

Steps to reproduce

test = undefined
  where
    -- | Comment
    a = undefined

Compile with ghc -ddump-parsed-ast. The comment is absent from the parse tree.

Expected behavior

I expected the comment to be present in the parse tree. GHC is inconsistent here, e.g. it has no qualms with preserving -- ^ comments in this example:

a = undefined
  where
    foo :: Int -- ^ a
        -> Bool -- ^ b
    foo = undefined

Environment

  • GHC version used: 8.8.1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information