summaryrefslogtreecommitdiff
path: root/compiler/typecheck/Inst.hs
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2016-03-29 12:42:16 +0200
committerBen Gamari <ben@smart-cactus.org>2016-03-29 12:42:17 +0200
commita49228e3b6e3737da750bce59ec721b3b2f18eed (patch)
treebf8937fe08b43e1d5c3aad9fc15cbbe82b14f9ef /compiler/typecheck/Inst.hs
parent73935326e0cf85ed077b9ab7dd8f197d39e2cd5b (diff)
downloadhaskell-a49228e3b6e3737da750bce59ec721b3b2f18eed.tar.gz
Build correct substitution in instDFunType
We will use `ty` in the range of the substitution, hence the substitution needs `ty`'s free vars in-scope. They don't seem easily available by other means, so we just compute them. Test Plan: ./validate Reviewers: austin, goldfire, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2043 GHC Trac Issues: #11371
Diffstat (limited to 'compiler/typecheck/Inst.hs')
-rw-r--r--compiler/typecheck/Inst.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/typecheck/Inst.hs b/compiler/typecheck/Inst.hs
index ab9a4e28c7..49f57a59b1 100644
--- a/compiler/typecheck/Inst.hs
+++ b/compiler/typecheck/Inst.hs
@@ -306,14 +306,16 @@ 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, substThetaUnchecked subst dfun_theta) }
+ ; return (inst_tys, substTheta subst dfun_theta) }
where
(dfun_tvs, dfun_theta, _) = tcSplitSigmaTy (idType dfun_id)
go :: TCvSubst -> [TyVar] -> [DFunInstType] -> TcM (TCvSubst, [TcType])
go subst [] [] = return (subst, [])
go subst (tv:tvs) (Just ty : mb_tys)
- = do { (subst', tys) <- go (extendTvSubst subst tv ty) tvs mb_tys
+ = do { (subst', tys) <- go (extendTvSubstAndInScope subst tv ty)
+ tvs
+ mb_tys
; return (subst', ty : tys) }
go subst (tv:tvs) (Nothing : mb_tys)
= do { (subst', tv') <- newMetaTyVarX subst tv