diff options
author | Bartosz Nitka <niteria@gmail.com> | 2016-03-29 12:42:16 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-03-29 12:42:17 +0200 |
commit | a49228e3b6e3737da750bce59ec721b3b2f18eed (patch) | |
tree | bf8937fe08b43e1d5c3aad9fc15cbbe82b14f9ef | |
parent | 73935326e0cf85ed077b9ab7dd8f197d39e2cd5b (diff) | |
download | haskell-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
-rw-r--r-- | compiler/typecheck/Inst.hs | 6 |
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 |