summaryrefslogtreecommitdiff
path: root/compiler/GHC
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-04-22 11:17:30 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-22 14:14:12 -0400
commit1e4dcf230a50b00350e084ca43e9d098ff865b22 (patch)
tree19b06c8109563d9715991aed595e13c935165137 /compiler/GHC
parent56d7cb538fc486bdb92ec9c911e7ad04f5522b77 (diff)
downloadhaskell-1e4dcf230a50b00350e084ca43e9d098ff865b22.tar.gz
decideMonoTyVars: account for CoVars in candidates
The "candidates" passed to decideMonoTyVars can contain coercion holes. This is because we might well decide to quantify over some unsolved equality constraints, as long as they are not definitely insoluble. In that situation, decideMonoTyVars was passing a set of type variables that was not closed over kinds to closeWrtFunDeps, which was tripping up an assertion failure. Fixes #21404
Diffstat (limited to 'compiler/GHC')
-rw-r--r--compiler/GHC/Tc/Instance/FunDeps.hs6
-rw-r--r--compiler/GHC/Tc/Solver.hs2
2 files changed, 5 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Instance/FunDeps.hs b/compiler/GHC/Tc/Instance/FunDeps.hs
index e3baf4c4f9..5b215490af 100644
--- a/compiler/GHC/Tc/Instance/FunDeps.hs
+++ b/compiler/GHC/Tc/Instance/FunDeps.hs
@@ -44,7 +44,6 @@ import GHC.Utils.FV
import GHC.Utils.Error( Validity'(..), Validity, allValid )
import GHC.Utils.Misc
import GHC.Utils.Panic
-import GHC.Utils.Panic.Plain ( assert )
import GHC.Data.Pair ( Pair(..) )
import Data.List ( nubBy )
@@ -552,7 +551,10 @@ closeWrtFunDeps :: [PredType] -> TyCoVarSet -> TyCoVarSet
-- See Note [The liberal coverage condition]
closeWrtFunDeps preds fixed_tvs
| null tv_fds = fixed_tvs -- Fast escape hatch for common case.
- | otherwise = assert (closeOverKinds fixed_tvs == fixed_tvs)
+ | otherwise = assertPpr (closeOverKinds fixed_tvs == fixed_tvs)
+ (vcat [ text "closeWrtFunDeps: fixed_tvs is not closed over kinds"
+ , text "fixed_tvs:" <+> ppr fixed_tvs
+ , text "closure:" <+> ppr (closeOverKinds fixed_tvs) ])
$ fixVarSet extend fixed_tvs
where
diff --git a/compiler/GHC/Tc/Solver.hs b/compiler/GHC/Tc/Solver.hs
index 1ea5ba7de1..31e2f7ed93 100644
--- a/compiler/GHC/Tc/Solver.hs
+++ b/compiler/GHC/Tc/Solver.hs
@@ -1672,7 +1672,7 @@ decideMonoTyVars infer_mode name_taus psigs candidates
; tc_lvl <- TcM.getTcLevel
; let psig_tys = mkTyVarTys psig_qtvs ++ psig_theta
- co_vars = coVarsOfTypes (psig_tys ++ taus)
+ co_vars = coVarsOfTypes (psig_tys ++ taus ++ candidates)
co_var_tvs = closeOverKinds co_vars
-- The co_var_tvs are tvs mentioned in the types of covars or
-- coercion holes. We can't quantify over these covars, so we