GHC in -haddock mode can't handle docstrings on unnamed constructor fields
Summary
GHC is broken in various ways on declarations like this:
data Foo
= -- | Bar
Bar
-- | Field 1
Int
Steps to reproduce
Exhibit A, parse error on a valid docstring
data Foo
= -- | Bar
Bar
-- | Field 1
Int
$ ghc -haddock /tmp/x.hs
[1 of 1] Compiling Foo ( /tmp/x.hs, /tmp/x.o )
/tmp/x.hs:7:7: error: parse error on input ‘Int’
|
7 | Int
| ^^^
Exhibit B, docstring missing from parse tree
data Foo
= -- | Bar
Bar
Int -- ^ Field 1
ghc -haddock /tmp/x.hs -fforce-recomp -ddump-parsed
[1 of 1] Compiling Foo ( /tmp/x.hs, /tmp/x.o )
==================== Parser ====================
module Foo where
data Foo = " Bar" Bar Int
Expected behavior
Case (A) should parse successfully. Case (B) should retain the docstring for the field in the parse tree.
Environment
- GHC version used: HEAD as of Oct 30 (commit 01ef3e1f)