Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#11662 closed bug (fixed)

Regression using NamedFieldPuns with qualified field names

Reported by: hesselink Owned by: adamgundry
Priority: highest Milestone: 8.0.1
Component: Compiler (Parser) Version: 8.0.1-rc2
Keywords: ORF Cc: adamgundry
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: rename/should_compile/T11662
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D1965
Wiki Page:


I found a regression where code using the NamedFieldPuns extension and qualified field names doesn't compile with GHC 8 rc2, where it did with GHC 7.10.

Minimal reproduction:

module Rec where

data Rec = Rec { f :: Integer }


{-# LANGUAGE NamedFieldPuns #-}
module Main where

import Rec (Rec (Rec))
import qualified Rec

g :: Rec -> Integer
g (Rec { Rec.f }) = f

On GHC 8 this fails with:

Main.hs:6:10: error: Qualified name in binding position: Rec.f

Change History (7)

comment:1 Changed 4 years ago by hesselink

One more addition: I'm pretty sure now that this is supposed to work (and wasn't an accidental feature), since the documentation states

A pun on a qualified field name is expanded by stripping off the module qualifier.

comment:2 Changed 4 years ago by bgamari

Cc: adamgundry added
Component: CompilerCompiler (Parser)
Milestone: 8.0.1
Priority: normalhighest

Indeed, it seems to me like this should work. It seems likely that this is due to the rework surrounding record selectors which accompanied DuplicateRecordFields. Ccing Adam.

comment:3 Changed 4 years ago by adamgundry

Owner: set to adamgundry

Sounds plausible. I'll take a look.

comment:4 Changed 4 years ago by adamgundry

Differential Rev(s): Phab:D1965
Keywords: ORF added
Status: newpatch
Test Case: rename/should_compile/T11662

comment:5 Changed 4 years ago by Ben Gamari <ben@…>

In bd681bce/ghc:

Drop module qualifier from punned record fields (#11662)

A record pattern match, construction or update like
`Rec { Mod.f }` should expand to `Rec { Mod.f = f }` rather
than `Rec { Mod.f = Mod.f }`.

Test Plan: New test rename/should_compile/T11662

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: hesselink, thomie

Differential Revision:

GHC Trac Issues: #11662

comment:6 Changed 4 years ago by bgamari

Status: patchmerge

comment:7 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed
Last edited 4 years ago by bgamari (previous) (diff)
Note: See TracTickets for help on using tickets.