[commit: ghc] master: Make isInsolubleOccursCheck more aggressive (c2eea08)

git at git.haskell.org git at git.haskell.org
Fri May 26 08:55:20 UTC 2017


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

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

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

commit c2eea089e7978416c6882a5456117db27b8f45ba
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri May 26 09:27:08 2017 +0100

    Make isInsolubleOccursCheck more aggressive
    
    Consider
      type family F a :: * -> *
    
    Then (a ~ F Int a) is an insoluble occurs check, and can be reported
    as such.  Previous to this patch, TcType.isInsolubleOccursCheck was
    treating any type-family application (including an over-saturated one)
    as unconditionally not-insoluble.
    
    This really only affects error messages, and then only slightly. I
    tripped over this when investigating  Trac #13674.


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

c2eea089e7978416c6882a5456117db27b8f45ba
 compiler/typecheck/TcType.hs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs
index ab2f843..bd72981 100644
--- a/compiler/typecheck/TcType.hs
+++ b/compiler/typecheck/TcType.hs
@@ -2152,7 +2152,9 @@ isInsolubleOccursCheck eq_rel tv ty
     go (CoercionTy _) = False   -- ToDo: what about the coercion
     go (TyConApp tc tys)
       | isGenerativeTyCon tc role = any go tys
-      | otherwise                 = False
+      | otherwise                 = any go (drop (tyConArity tc) tys)
+         -- (a ~ F b a), where F has arity 1,
+         -- has an insoluble occurs check
 
     role = eqRelRole eq_rel
 



More information about the ghc-commits mailing list