[commit: ghc] wip/rae: Fix Trac #9371. (0766407)
git at git.haskell.org
git at git.haskell.org
Fri Aug 8 18:59:47 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/rae
Link : http://ghc.haskell.org/trac/ghc/changeset/0766407454e1f324ab49b6136a8b7b02c5a4aa02/ghc
>---------------------------------------------------------------
commit 0766407454e1f324ab49b6136a8b7b02c5a4aa02
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date: Sun Aug 3 18:40:30 2014 -0400
Fix Trac #9371.
This was very simple: lists of different lengths are
*maybe* apart, not *surely* apart.
>---------------------------------------------------------------
0766407454e1f324ab49b6136a8b7b02c5a4aa02
compiler/types/Unify.lhs | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/compiler/types/Unify.lhs b/compiler/types/Unify.lhs
index f44e260..1eb1c2b 100644
--- a/compiler/types/Unify.lhs
+++ b/compiler/types/Unify.lhs
@@ -418,6 +418,26 @@ substituted, we can't properly unify the types. But, that skolem variable
may later be instantiated with a unifyable type. So, we return maybeApart
in these cases.
+Note [Lists of different lengths are MaybeApart]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+It is unusual to call tcUnifyTys or tcUnifyTysFG with lists of different
+lengths. The place where we know this can happen is from compatibleBranches in
+FamInstEnv, when checking data family instances. Data family instances may be
+eta-reduced; see Note [Eta reduction for data family axioms] in TcInstDcls.
+
+We wish to say that
+
+ D :: * -> * -> *
+ axDF1 :: D Int ~ DFInst1
+ axDF2 :: D Int Bool ~ DFInst2
+
+overlap. If we conclude that lists of different lengths are SurelyApart, then
+it will look like these do *not* overlap, causing disaster. See Trac #9371.
+
+In usages of tcUnifyTys outside of family instances, we always use tcUnifyTys,
+which can't tell the difference between MaybeApart and SurelyApart, so those
+usages won't notice this design choice.
+
\begin{code}
tcUnifyTy :: Type -> Type -- All tyvars are bindable
-> Maybe TvSubst -- A regular one-shot (idempotent) substitution
@@ -593,7 +613,7 @@ unifyList subst orig_xs orig_ys
go subst [] [] = return subst
go subst (x:xs) (y:ys) = do { subst' <- unify subst x y
; go subst' xs ys }
- go _ _ _ = surelyApart
+ go subst _ _ = maybeApart subst -- See Note [Lists of different lengths are MaybeApart]
---------------------------------
uVar :: TvSubstEnv -- An existing substitution to extend
More information about the ghc-commits
mailing list