summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs/Binds.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2020-07-28 10:55:25 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-08-19 18:48:14 -0400
commiteb9bdaef6024558696e1e50b12d7fefb70483a9f (patch)
treec6d13c6f1fb212746a627397e13308c830e9635f /compiler/GHC/Hs/Binds.hs
parent731c8d3bc5a84515793e5dadb26adf52f9280e13 (diff)
downloadhaskell-eb9bdaef6024558696e1e50b12d7fefb70483a9f.tar.gz
Add right-to-left rule for pattern bindings
Fix #18323 by adding a few lines of code to handle non-recursive pattern bindings. see GHC.Tc.Gen.Bind Note [Special case for non-recursive pattern bindings] Alas, this confused the pattern-match overlap checker; see #18323. Note that this patch only affects pattern bindings like that for (x,y) in this program combine :: (forall a . [a] -> a) -> [forall a. a -> a] -> ((forall a . [a] -> a), [forall a. a -> a]) breaks = let (x,y) = combine head ids in x y True We need ImpredicativeTypes for those [forall a. a->a] types to be valid. And with ImpredicativeTypes the old, unprincipled "allow unification variables to unify with a polytype" story actually works quite well. So this test compiles fine (if delicatedly) with old GHCs; but not with QuickLook unless we add this patch
Diffstat (limited to 'compiler/GHC/Hs/Binds.hs')
-rw-r--r--compiler/GHC/Hs/Binds.hs7
1 files changed, 1 insertions, 6 deletions
diff --git a/compiler/GHC/Hs/Binds.hs b/compiler/GHC/Hs/Binds.hs
index 0933e9ba7e..327aeea2c0 100644
--- a/compiler/GHC/Hs/Binds.hs
+++ b/compiler/GHC/Hs/Binds.hs
@@ -317,18 +317,13 @@ data HsBindLR idL idR
| XHsBindsLR !(XXHsBindsLR idL idR)
-data NPatBindTc = NPatBindTc {
- pat_fvs :: NameSet, -- ^ Free variables
- pat_rhs_ty :: Type -- ^ Type of the GRHSs
- } deriving Data
-
type instance XFunBind (GhcPass pL) GhcPs = NoExtField
type instance XFunBind (GhcPass pL) GhcRn = NameSet -- Free variables
type instance XFunBind (GhcPass pL) GhcTc = HsWrapper -- See comments on FunBind.fun_ext
type instance XPatBind GhcPs (GhcPass pR) = NoExtField
type instance XPatBind GhcRn (GhcPass pR) = NameSet -- Free variables
-type instance XPatBind GhcTc (GhcPass pR) = NPatBindTc
+type instance XPatBind GhcTc (GhcPass pR) = Type -- Type of the GRHSs
type instance XVarBind (GhcPass pL) (GhcPass pR) = NoExtField
type instance XAbsBinds (GhcPass pL) (GhcPass pR) = NoExtField