Postfix Haddock comments on unnamed constructor fields can be lost
Summary
The -- ^
comment here is lost from the parse tree:
data Foo
= -- | Cons 1
Cons
Int -- ^ Field 1
ghc -haddock -fforce-recomp -ddump-parsed /tmp/z.hs
[1 of 1] Compiling Main ( /tmp/z.hs, /tmp/z.o )
==================== Parser ====================
data Foo = " Cons 1" Cons Int
Notes
The comment is treated as a constructor Haddock if -- | Cons 1
is removed (this is also questionable behavior):
data Foo
= Cons
Int -- ^ Field 1
==================== Parser ====================
data Foo = " Field 1" Cons Int
The comment is treated as a field Haddock if there is more than one field (this is the right behavior):
data Foo
= Cons
Int -- ^ Field 1
Bool -- ^ Field 2
==================== Parser ====================
data Foo = Cons Int " Field 1" Bool " Field 2"
Environment
- GHC version used: 8.9.0.20191031