Skip to content

Poor error message for ambiguous occurrence of duplicate data family field

{-# LANGUAGE DuplicateRecordFields, TypeFamilies #-}

module T23301 where

data family D a
data instance D Int  = MkD1 { fld :: Int }
data instance D Bool = MkD2 { fld :: Bool }

foo = fld
    Ambiguous occurrence `fld'
    It could refer to
       either the field `fld' of record `D', defined at T23301.hs:6:31
           or the field `fld' of record `D', defined at T23301.hs:7:31

The message says "of record `D'", which is rather confusing. It's even worse if the data family field is imported, as then we get the same source location for both!

Edited by sheaf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information