Name shadowing with PatternSynonyms + RecordWildCards
Summary
GHC incorrectly warns about name shadowing with the extensions. Generated code still behaves correctly.
Steps to reproduce
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}
pattern Point :: Int -> Int
pattern Point{x} = x
{-# COMPLETE Point #-}
foo :: Int
foo = let x = 2 in Point{..}
bar :: Int -> Int
bar Point{..} = x
main :: IO ()
main = print (foo + bar foo) -- "4" - OK!
{-
Tested with ghc-8.6.5 and ghc-8.8.3
$ stack ghc patterns.hs --resolver lts-15.10 -- -Wall
Stack has not been tested with GHC versions above 8.6, and using 8.8.3, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
[1 of 1] Compiling Main ( patterns.hs, patterns.o )
patterns.hs:10:11: warning: [-Wname-shadowing]
This binding for ‘x’ shadows the existing binding
defined at patterns.hs:5:15
|
10 | foo = let x = 2 in Point{..}
| ^
patterns.hs:13:5: warning: [-Wname-shadowing]
This binding for ‘x’ shadows the existing binding
defined at patterns.hs:5:15
|
13 | bar Point{..} = x
| ^^^^^^^^^
Linking patterns ...
-}
Expected behavior
No name-shadowing warnings.
Environment
- GHC version used: 8.8.3, 8.6.5
Optional: