Type-directed disambiguation doesn't work for record updates using pattern synonyms; poor error message
{-# LANGUAGE DuplicateRecordFields, PatternSynonyms #-}
module T21946 where
pattern R1 :: Int -> Int
pattern R1 { fld } = fld
pattern R2 :: Bool -> Bool
pattern R2 { fld } = fld
f r = (r :: Int) { fld = undefined }
This fails with the error message:
* `fld' is not a (visible) field of type `Int'
* In the expression: (r :: Int) {fld = undefined}
In an equation for `f': f r = (r :: Int) {fld = undefined}
|
| f r = (r :: Int) { fld = undefined }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If one removes the definition of R2 then it works.
This is because the logic in GHC.Tc.Gen.Expr.identifyParent only deals with the TyCon parent case, and not the PatSyn parent case. But this type-directed disambiguation is scheduled to be removed in the future anyway.
Edited by sheaf