summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Solver/Interact.hs
diff options
context:
space:
mode:
authorRichard Eisenberg <rae@richarde.dev>2021-01-05 22:40:53 -0500
committerRichard Eisenberg <rae@richarde.dev>2021-01-15 23:14:13 -0500
commit7d550ff71ee06c681756f60fbd3731559484afa3 (patch)
treeeab8a083e327c06272f1c95833174ecf347bea45 /compiler/GHC/Tc/Solver/Interact.hs
parent0dba78410887ffc3d219639081e284ef7b67560a (diff)
downloadhaskell-wip/T19106.tar.gz
Make matchableGivens more reliably correct.wip/T19106
This has two fixes: 1. Take TyVarTvs into account in matchableGivens. This fixes #19106. 2. Don't allow unifying alpha ~ Maybe alpha. This fixes #19107. This patch also removes a redundant Note and redirects references to a better replacement. Also some refactoring/improvements around the BindFun in the pure unifier, which now can take the RHS type into account. Close #19106. Close #19107. Test case: partial-sigs/should_compile/T19106, typecheck/should_compile/T19107
Diffstat (limited to 'compiler/GHC/Tc/Solver/Interact.hs')
-rw-r--r--compiler/GHC/Tc/Solver/Interact.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/GHC/Tc/Solver/Interact.hs b/compiler/GHC/Tc/Solver/Interact.hs
index e8ab8ad82a..b02b22f854 100644
--- a/compiler/GHC/Tc/Solver/Interact.hs
+++ b/compiler/GHC/Tc/Solver/Interact.hs
@@ -2151,7 +2151,7 @@ Other notes:
- natural numbers
- Typeable
-* See also Note [What might match later?] in GHC.Tc.Solver.Monad.
+* See also Note [What might equal later?] in GHC.Tc.Solver.Monad.
* The given-overlap problem is arguably not easy to appear in practice
due to our aggressive prioritization of equality solving over other
@@ -2263,8 +2263,8 @@ matchLocalInst :: TcPredType -> CtLoc -> TcS ClsInstResult
-- Look up the predicate in Given quantified constraints,
-- which are effectively just local instance declarations.
matchLocalInst pred loc
- = do { ics <- getInertCans
- ; case match_local_inst (inert_insts ics) of
+ = do { inerts@(IS { inert_cans = ics }) <- getTcSInerts
+ ; case match_local_inst inerts (inert_insts ics) of
([], False) -> do { traceTcS "No local instance for" (ppr pred)
; return NoInstance }
([(dfun_ev, inst_tys)], unifs)
@@ -2281,14 +2281,15 @@ matchLocalInst pred loc
where
pred_tv_set = tyCoVarsOfType pred
- match_local_inst :: [QCInst]
+ match_local_inst :: InertSet
+ -> [QCInst]
-> ( [(CtEvidence, [DFunInstType])]
, Bool ) -- True <=> Some unify but do not match
- match_local_inst []
+ match_local_inst _inerts []
= ([], False)
- match_local_inst (qci@(QCI { qci_tvs = qtvs, qci_pred = qpred
+ match_local_inst inerts (qci@(QCI { qci_tvs = qtvs, qci_pred = qpred
, qci_ev = ev })
- : qcis)
+ : qcis)
| let in_scope = mkInScopeSet (qtv_set `unionVarSet` pred_tv_set)
, Just tv_subst <- ruleMatchTyKiX qtv_set (mkRnEnv2 in_scope)
emptyTvSubstEnv qpred pred
@@ -2303,5 +2304,5 @@ matchLocalInst pred loc
(matches, unif || this_unif)
where
qtv_set = mkVarSet qtvs
- this_unif = mightMatchLater qpred (ctEvLoc ev) pred loc
- (matches, unif) = match_local_inst qcis
+ this_unif = mightEqualLater inerts qpred (ctEvLoc ev) pred loc
+ (matches, unif) = match_local_inst inerts qcis