Skip to content

DisambiguateRecordFields fails for PatternSynonyms

Consider:

{-# 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.

Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related #11283 (closed)
Blocking
CC mpickering
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information