[commit: ghc] master: Fix invariant in mkAppCoFlexible (21f17d0)

git at git.haskell.org git at git.haskell.org
Tue May 13 12:17:50 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/21f17d06aa5c33e639f1b0d37b4bf888b494c441/ghc

>---------------------------------------------------------------

commit 21f17d06aa5c33e639f1b0d37b4bf888b494c441
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue May 13 13:17:19 2014 +0100

    Fix invariant in mkAppCoFlexible
    
    mkAppCoFlexible was breaking the invariant that the head of a TyConAppCo cannot
    be a type synonym.  This small patch fixes it.


>---------------------------------------------------------------

21f17d06aa5c33e639f1b0d37b4bf888b494c441
 compiler/types/Coercion.lhs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler/types/Coercion.lhs b/compiler/types/Coercion.lhs
index 195bc4c..a8f9a2e 100644
--- a/compiler/types/Coercion.lhs
+++ b/compiler/types/Coercion.lhs
@@ -948,7 +948,9 @@ mkAppCo co1 co2 = mkAppCoFlexible co1 Nominal co2
 mkAppCoFlexible :: Coercion -> Role -> Coercion -> Coercion
 mkAppCoFlexible (Refl r ty1) _ (Refl _ ty2)
   = Refl r (mkAppTy ty1 ty2)
-mkAppCoFlexible (Refl r (TyConApp tc tys)) r2 co2
+mkAppCoFlexible (Refl r ty1) r2 co2
+  | Just (tc, tys) <- splitTyConApp_maybe ty1
+    -- Expand type synonyms; a TyConAppCo can't have a type synonym (Trac #9102)
   = TyConAppCo r tc (zip_roles (tyConRolesX r tc) tys)
   where
     zip_roles (r1:_)  []        = [downgradeRole r1 r2 co2]



More information about the ghc-commits mailing list