[GHC] #15206: Strictness annotations bind more tightly than doc strings on non-record data declarations

GHC ghc-devs at haskell.org
Thu May 31 15:38:59 UTC 2018


#15206: Strictness annotations bind more tightly than doc strings on non-record
data declarations
-------------------------------------+-------------------------------------
           Reporter:  harpocrates    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.5
  (Parser)                           |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  GHC rejects
  Unknown/Multiple                   |  valid program
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):  Phab:D4727     |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider the following declaration:

 {{{#!hs
 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"}))))))
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15206>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list