Skip to content

Pattern matching duplicated record fields

GHC panic during compiling pattern matching with duplicated record fields. The following is a short example.

Main module:

module Lib
    ( someFunc
    ) where

import F1
import qualified F2

r :: F2.T2
r = F2.T2 {
  F2.foo = "ok"
}

someFunc :: IO ()
someFunc = case r of
  F2.T2{ foo = a } -> putStrLn a

The first submodule:

module F1
    ( T1(..)
    ) where

newtype T1 = T1 {
  foo :: String
}

The second submodule:

module F2
    ( T2(..)
    ) where

newtype T2 = T2 {
  foo :: String
}

GHC compiles the modules successfully if uses DuplicateRecordFields.

The modules may be not correct without DuplicateRecordFields. But GHC should show an error message other than panic.

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information