Opened 5 weeks ago

Last modified 2 weeks ago

#13847 new bug

record construction accepts local unqualified name instead of qualified imported name

Reported by: j.waldmann Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.0.1
Keywords: ORF Cc: adamgundry
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC accepts invalid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:



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 = () 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?

Change History (4)

comment:1 Changed 5 weeks ago by mpickering

This is rejected by 7.10.3, but not by 8.0.2.

comment:2 Changed 5 weeks ago by RyanGlScott

Cc: adamgundry added

This regression was introduced in b1884b0e62f62e3c0859515c4137124ab0c9560e (Implement DuplicateRecordFields).

comment:3 Changed 4 weeks ago by adamgundry

Mea culpa. I'll try to take a look at this at some point, but my spare cycles are desperately limited at the moment, so if someone else wants to jump in first then feel free.

comment:4 Changed 2 weeks ago by adamgundry

Keywords: ORF added
Note: See TracTickets for help on using tickets.