Opened 3 months ago

Closed 3 days ago

#13847 closed bug (fixed)

record construction accepts local unqualified name instead of qualified imported name

Reported by: j.waldmann Owned by:
Priority: normal Milestone: 8.4.1
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: rename/should_fail/T13847
Blocked By: Blocking:
Related Tickets: #13644 Differential Rev(s): Phab:D3988
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 (7)

comment:1 Changed 3 months ago by mpickering

This is rejected by 7.10.3, but not by 8.0.2.

comment:2 Changed 3 months ago by RyanGlScott

Cc: adamgundry added

This regression was introduced in b1884b0e62f62e3c0859515c4137124ab0c9560e (Implement DuplicateRecordFields).

comment:3 Changed 3 months 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 3 months ago by adamgundry

Keywords: ORF added

comment:5 Changed 6 days ago by adamgundry

Differential Rev(s): Phab:D3988
Milestone: 8.4.1
Status: newpatch
Test Case: rename/should_fail/T13847

comment:6 Changed 3 days ago by Ben Gamari <ben@…>

In 72b00c34/ghc:

Identify fields by selector when type-checking (fixes #13644)

Test Plan: new test for #13847, and the test for #13644 now passes

Reviewers: mpickering, austin, bgamari, simonpj

Reviewed By: mpickering, simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13644, #13847

Differential Revision:

comment:7 Changed 3 days ago by adamgundry

Resolution: fixed
Status: patchclosed
Note: See TracTickets for help on using tickets.