diff options
author | Bartosz Nitka <niteria@gmail.com> | 2016-01-27 08:37:30 -0800 |
---|---|---|
committer | Bartosz Nitka <niteria@gmail.com> | 2016-01-30 08:41:21 -0800 |
commit | bb956eb8d8774613c1e311655f1359a91a84765b (patch) | |
tree | a50acf0ff74796455432a3f9c2469fbc8df8afb0 /compiler/typecheck/Inst.hs | |
parent | bc83c733e58939e1ff0d5eea9dca359615203ea4 (diff) | |
download | haskell-bb956eb8d8774613c1e311655f1359a91a84765b.tar.gz |
Add asserts to other substitution functions
This adds asserts to `substTys`, `substCo` and `substCos` in
the same spirit as already existing asserts on `substTy`, protecting
every possible entry point to `subst_ty` and `subst_co`.
I've replaced the violators with unchecked versions.
Test Plan: ./validate --slow
Reviewers: simonpj, goldfire, austin, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1862
GHC Trac Issues: #11371
Diffstat (limited to 'compiler/typecheck/Inst.hs')
-rw-r--r-- | compiler/typecheck/Inst.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/typecheck/Inst.hs b/compiler/typecheck/Inst.hs index fe17d52d7a..f142dcaa75 100644 --- a/compiler/typecheck/Inst.hs +++ b/compiler/typecheck/Inst.hs @@ -136,7 +136,7 @@ deeplySkolemise ty | Just (arg_tys, tvs, theta, ty') <- tcDeepSplitSigmaTy_maybe ty = do { ids1 <- newSysLocalIds (fsLit "dk") arg_tys ; (subst, tvs1) <- tcInstSkolTyVars tvs - ; ev_vars1 <- newEvVars (substTheta subst theta) + ; ev_vars1 <- newEvVars (substThetaUnchecked subst theta) ; (wrap, tvs2, ev_vars2, rho) <- deeplySkolemise (substTyAddInScope subst ty') ; return ( mkWpLams ids1 @@ -178,7 +178,7 @@ top_instantiate inst_all orig ty | null leave_bndrs = (theta, []) | otherwise = ([], theta) ; (subst, inst_tvs') <- newMetaTyVars (map (binderVar "top_inst") inst_bndrs) - ; let inst_theta' = substTheta subst inst_theta + ; let inst_theta' = substThetaUnchecked subst inst_theta sigma' = substTyAddInScope subst (mkForAllTys leave_bndrs $ mkFunTys leave_theta rho) @@ -221,8 +221,8 @@ deeplyInstantiate :: CtOrigin -> TcSigmaType -> TcM (HsWrapper, TcRhoType) deeplyInstantiate orig ty | Just (arg_tys, tvs, theta, rho) <- tcDeepSplitSigmaTy_maybe ty = do { (subst, tvs') <- newMetaTyVars tvs - ; ids1 <- newSysLocalIds (fsLit "di") (substTys subst arg_tys) - ; let theta' = substTheta subst theta + ; ids1 <- newSysLocalIds (fsLit "di") (substTysUnchecked subst arg_tys) + ; let theta' = substThetaUnchecked subst theta ; wrap1 <- instCall orig (mkTyVarTys tvs') theta' ; traceTc "Instantiating (deeply)" (vcat [ text "origin" <+> pprCtOrigin orig , text "type" <+> ppr ty @@ -302,7 +302,7 @@ instDFunType :: DFunId -> [DFunInstType] -- See Note [DFunInstType: instantiating types] in InstEnv instDFunType dfun_id dfun_inst_tys = do { (subst, inst_tys) <- go emptyTCvSubst dfun_tvs dfun_inst_tys - ; return (inst_tys, substTheta subst dfun_theta) } + ; return (inst_tys, substThetaUnchecked subst dfun_theta) } where (dfun_tvs, dfun_theta, _) = tcSplitSigmaTy (idType dfun_id) |