Opened 2 years ago

Closed 20 months ago

#14747 closed bug (fixed)

DisambiguateRecordFields fails for PatternSynonyms

Reported by: adamgundry Owned by: adamgundry
Priority: normal Milestone: 8.6.1
Component: Compiler (Type checker) Version: 8.2.1
Keywords: PatternSynonyms Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: rename/should_compile/T14747
Blocked By: Blocking:
Related Tickets: #11283, #15149 Differential Rev(s): Phab:D4821
Wiki Page:



{-# LANGUAGE PatternSynonyms #-}

module A where

pattern S{x} = [x]
{-# LANGUAGE PatternSynonyms, DisambiguateRecordFields #-}

module B where

import A

pattern T{x} = [x]

e = S { x = 42 }

Compiling module B fails with Ambiguous occurrence ‘x’ in the definition of e. In principle, DisambiguateRecordFields should select the field belonging to the S "data constructor". However, the current implementation of this works by identifying the parent type constructor, which doesn't exist for a pattern synonym.

This continues to fail if T is replaced by a data type with a field x. If S is replaced by a data type, however, it starts working.

Change History (4)

comment:1 Changed 20 months ago by adamgundry

Owner: set to adamgundry

#15149 outlines a plan that should allow fixing this.

comment:2 Changed 20 months ago by adamgundry

Differential Rev(s): Phab:D4821
Status: newpatch
Test Case: rename/should_compile/T14747

comment:3 Changed 20 months ago by Ben Gamari <ben@…>

In 7100850e/ghc:

Use data con name instead of parent in lookupRecFieldOcc

Test Plan: new tests rename/should_compile/{T14747,T15149}

Reviewers: simonpj, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14747, #15149

Differential Revision:

comment:4 Changed 20 months ago by bgamari

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