Problems disambiguating a record update with pattern synonyms
The parent of a pattern synonym record field is the pattern synonym itself, which I think makes sense (a pattern synonym behaves much like a data constructor). However, it seems that the following variant on #21443 (closed) causes GHC to trip over:
{-# LANGUAGE DuplicateRecordFields, PatternSynonyms #-}
pattern P :: Int -> Int -> (Int, Int)
pattern P { proj_x, proj_y } = (proj_x, proj_y)
pattern Q1 :: Int -> Int
pattern Q1 { proj_x } = proj_x
pattern Q2 :: Int -> Int
pattern Q2 { proj_y } = proj_y
blah :: (Int, Int) -> (Int, Int)
blah p = p { proj_x = 0, proj_y = 1 }
error:
* GHC internal error: `T21443b.$sel:proj_x:P' is not in scope during type checking, but it passed the renamer
tcl_env of environment: [auv :-> Identifier[p::(Int,
Int), NotLetBound],
rgF :-> Identifier[blah::(Int, Int)
-> (Int, Int), TopLevelLet {} True]]
* In the expression: p {proj_x = 0, proj_y = 1}
In an equation for `blah': blah p = p {proj_x = 0, proj_y = 1}
|
| blah p = p { proj_x = 0, proj_y = 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^