Strictness annotations bind more tightly than doc strings on non-record data declarations
Consider the following declaration:
data Point = Point -- ^ a 2D point
!Int -- ^ x coord
!Int -- ^ y coord
With -haddock enabled, the first field parses as
({ bad.hs:2:16-32 }
(HsDocTy
({ bad.hs:2:16-19 }
(HsBangTy
(HsSrcBang
(NoSourceText)
(NoSrcUnpack)
(SrcStrict))
({ bad.hs:2:17-19 }
(HsTyVar
(NotPromoted)
({ bad.hs:2:17-19 }
(Unqual
{OccName: Int}))))))
({ bad.hs:2:21-32 }
(HsDocString
{FastString: " x coord"}))))
However, this is incorrect since further down the compilation pipeline, strictness and unpackedness annotations are only looked for at the top-level of a field (meaning the above example hits the strictness annotation cannot appear nested inside a type error).
We want this instead:
({ bad.hs:2:16-32 }
(HsBangTy
(NoExt)
(HsSrcBang
(NoSourceText)
(NoSrcUnpack)
(SrcStrict))
({ bad.hs:2:17-32 }
(HsDocTy
(NoExt)
({ bad.hs:2:17-19 }
(HsTyVar
(NoExt)
(NotPromoted)
({ bad.hs:2:17-19 }
(Unqual
{OccName: Int}))))
({ bad.hs:2:21-32 }
(HsDocString
{FastString: " x coord"}))))))
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.5 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Parser) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |