Skip to content
  • Georgi Lyubenov's avatar
    GHC proposal 496 - Nullary record wildcards · 172ff88f
    Georgi Lyubenov authored and Marge Bot's avatar Marge Bot committed
    This patch implements GHC proposal 496, which allows record wildcards
    to be used for nullary constructors, e.g.
    
      data A = MkA1 | MkA2 { fld1 :: Int }
      f :: A -> Int
      f (MkA1 {..}) = 0
      f (MkA2 {..}) = fld1
    
    To achieve this, we add arity information to the record field
    environment, so that we can accept a constructor which has no fields
    while continuing to reject non-record constructors with more than 1
    field. See Note [Nullary constructors and empty record wildcards],
    as well as the more general overview in Note [Local constructor info in the renamer],
    both in the newly introduced GHC.Types.ConInfo module.
    
    Fixes #22161
    172ff88f