Skip to content

Strange requirement for re-exported duplicate record fields

In the following example,

module A(A(..)) where
data A = A {x::Int}

module B(B(..)) where
data B = B {x::Bool}

{-# LANGUAGE DuplicateRecordFields #-}
module C(A(..),B(..)) where
import A(A(..))
import B(B(..))

I get an error about conflicting exports for 'x'. This doesn't seem right to me: I've got -XDuplicateRecordFields exactly where the duplicate occurs.

However, I noticed that the if I move the pragma to A.hs, C.hs compiles without error:

{-# LANGUAGE DuplicateRecordFields #-}
module A(A(..)) where
data A = A {x::Int}

module B(B(..)) where
data B = B {x::Bool}

module C(A(..),B(..)) where
import A(A(..))
import B(B(..))

This is bizarre because it is asymmetric (I arbitrarily put the pragma in A.hs, but it need not occur in B.hs), and because no duplicate records exist in module A, but they do exist in module C, where the pragma isn't needed.

Trac metadata
Trac field Value
Version 8.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by sheaf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information