diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2022-11-28 15:36:25 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-11-30 09:32:03 -0500 |
commit | a9d9b8c0458e838f331ead62dca272665ecbf20d (patch) | |
tree | 423877074f00e2ac8d690dd2fde71fa60cb58002 /compiler/GHC/Tc | |
parent | a3a8e9e968ff9b10c6785d53a5f1c8fcef6db72b (diff) | |
download | haskell-a9d9b8c0458e838f331ead62dca272665ecbf20d.tar.gz |
Use mkNakedFunTy in tcPatSynSig
As #22521 showed, in tcPatSynSig we make a "fake type" to
kind-generalise; and that type has unzonked type variables in it. So
we must not use `mkFunTy` (which checks FunTy's invariants) via
`mkPhiTy` when building this type. Instead we need to use
`mkNakedFunTy`.
Easy fix.
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r-- | compiler/GHC/Tc/Gen/Sig.hs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Gen/Sig.hs b/compiler/GHC/Tc/Gen/Sig.hs index b1e59a78b3..0c74bd54f6 100644 --- a/compiler/GHC/Tc/Gen/Sig.hs +++ b/compiler/GHC/Tc/Gen/Sig.hs @@ -52,9 +52,10 @@ import GHC.Tc.Types.Evidence( HsWrapper, (<.>) ) import GHC.Core( hasSomeUnfolding ) import GHC.Core.Type ( mkTyVarBinders ) import GHC.Core.Multiplicity +import GHC.Core.TyCo.Rep( mkNakedFunTy ) import GHC.Types.Error -import GHC.Types.Var ( TyVar, Specificity(..), tyVarKind, binderVars ) +import GHC.Types.Var ( TyVar, Specificity(..), tyVarKind, binderVars, invisArgTypeLike ) import GHC.Types.Id ( Id, idName, idType, setInlinePragma , mkLocalId, realIdUnfolding ) import GHC.Types.Basic @@ -485,11 +486,19 @@ tcPatSynSig name sig_ty@(L _ (HsSig{sig_bndrs = hs_outer_bndrs, sig_body = hs_ty build_patsyn_type implicit_bndrs univ_bndrs req ex_bndrs prov body = mkInvisForAllTys implicit_bndrs $ mkInvisForAllTys univ_bndrs $ - mkPhiTy req $ + mk_naked_phi_ty req $ mkInvisForAllTys ex_bndrs $ - mkPhiTy prov $ + mk_naked_phi_ty prov $ body + -- Use mk_naked_phi_ty because we call build_patsyn_type /before zonking/ + -- just before kindGeneraliseAll, and the invariants that mkPhiTy checks + -- don't hold of the un-zonked types. #22521 was a case in point. + -- (We also called build_patsyn_type on the fully zonked type, so mkPhiTy + -- would work; but it doesn't seem worth duplicating the code.) + mk_naked_phi_ty :: [TcPredType] -> TcType -> TcType + mk_naked_phi_ty theta body = foldr (mkNakedFunTy invisArgTypeLike) body theta + ppr_tvs :: [TyVar] -> SDoc ppr_tvs tvs = braces (vcat [ ppr tv <+> dcolon <+> ppr (tyVarKind tv) | tv <- tvs]) |