Opened 22 months ago

Closed 22 months ago

Last modified 21 months ago

#11173 closed bug (fixed)

Infix declarations for record fields with DuplicateRecordFields are broken

Reported by: kanetw Owned by: adamgundry
Priority: high Milestone: 8.0.1
Component: Compiler Version: 7.11
Keywords: ORF Cc: adamgundry
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: #11167 Differential Rev(s): Phab:D1600
Wiki Page:


The following program compiles fine

module Good where
newtype A = A { foo :: Int }
infixl 5 `foo`

but this one doesn't

{-# LANGUAGE DuplicateRecordFields #-}
module Bad where
newtype A = A { foo :: Int }
infixl 5 `foo`

giving an error

The fixity signature for ‘foo’ lacks an accompanying binding
 (The fixity signature must be given where ‘foo’ is declared)

Change History (7)

comment:1 Changed 22 months ago by hvr

Cc: adamgundry added
Keywords: regression added
Milestone: 8.0.1
Priority: normalhighest

comment:2 Changed 22 months ago by hvr

Keywords: regression removed
Priority: highesthigh

nevermind, not a regression

comment:3 Changed 22 months ago by adamgundry

Owner: set to adamgundry

I'll take a look at this. I think a similar issue applies to DEPRECATED pragmas and possibly other things that are keyed by OccName.

comment:4 Changed 22 months ago by adamgundry

Differential Rev(s): Phab:D1600
Status: newpatch

comment:5 Changed 22 months ago by Ben Gamari <ben@…>

In 6e56ac58/ghc:

Fix infix record field fixity (#11167 and #11173).

This extends D1585 with proper support for infix duplicate record
fields.  In particular, it is now possible to declare record fields as
infix in a module for which `DuplicateRecordFields` is enabled, fixity
is looked up correctly and a readable (although unpleasant) error
message is generated if multiple fields with different fixities are in

As a bonus, `DEPRECATED` and `WARNING` pragmas now work for
duplicate record fields. The pragma applies to all fields with the
given label.

In addition, a couple of minor `DuplicateRecordFields` bugs, which were
pinpointed by the `T11167_ambig` test case, are fixed by this patch:

  - Ambiguous infix fields can now be disambiguated by putting a type
    signature on the first argument

  - Polymorphic type constructor signatures (such as `ContT () IO a` in
    `T11167_ambig`) now work for disambiguation

Parts of this patch are from D1585 authored by @KaneTW.

Test Plan: New tests added.

Reviewers: KaneTW, bgamari, austin

Reviewed By: bgamari

Subscribers: thomie, hvr

Differential Revision:

GHC Trac Issues: #11167, #11173

comment:6 Changed 22 months ago by bgamari

Resolution: fixed
Status: patchclosed

comment:7 Changed 21 months ago by adamgundry

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