Skip to content

record construction accepts local unqualified name instead of qualified imported name

Given

module A where
data A = A { foo :: () } deriving Show 

the following code is accepted

module Main where
import qualified A
foo = "foo"
main = print $ A.A { foo = () }

albeit with a warning

B.hs:4:16: warning: [-Wmissing-fields]
    • Fields of ‘A.A’ not initialised: foo

Indeed the foo = () is type-checked as if it were A.foo = () but the foo field is actually not assigned. Evaluation gives

*Main> main
A {foo = *** Exception: B.hs:4:16-31: Missing field in record construction foo

The code should be rejected outright?

Trac metadata
Trac field Value
Version 8.0.1
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