DuplicateRecordFields fails compilation depending on the order of declarations
Summary
Builds with ghc 8.6.5:
{-# LANGUAGE DuplicateRecordFields #-}
main = return ()
newtype Record a = Record { f :: a -> a }
class C a where f :: a -> a
But flipping the order of the declarations
{-# LANGUAGE DuplicateRecordFields #-}
main = return ()
class C a where f :: a -> a
newtype Record a = Record { f :: a -> a }
gives
test2.hs:4:29: error:
Multiple declarations of ‘f’
Declared at: test2.hs:3:17
test2.hs:4:29
|
4 | newtype Record a = Record { f :: a -> a }
| ^
I guess this is a bug, but what is the expected behavior?
How to reproduce
Just invoke GHC passing the source-code file.
$ ghc test2.hs
Expected behavior
Both code snippets should either fail or succeed to build.
Environment
- GHC version used: 8.10.1, 8.6.5
- Operating System: nixos
- System Architecture: x86_64