DuplicateRecordFields appears not to work in GHCi
This was noticed shortly after the 8.0.1 announcement,
$ ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/ben/.ghci
λ> :set -XDuplicateRecordFields
λ> data A = A {test :: String}
λ> data B = B {test :: Int}
λ> print $ test (A 42)
<interactive>:4:9: error:
Ambiguous occurrence ‘test’
It could refer to either the field ‘test’,
defined at <interactive>:2:13
or the field ‘test’, defined at <interactive>:3:13
The equivalent program compiled as a module works as expected,
{-# LANGUAGE DuplicateRecordFields #-}
module Hi where
data A = A { test :: Int } deriving Show
data B = B { test :: String } deriving Show
x :: A
x = A 42
main = do
print x
print (A 42)
$ runghc Hi.hs
A {test = 42}
A {test = 42}
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |
Edited by Ben Gamari