[commit: ghc] ghc-7.8: In TcValidity.checkAmbiguity, skolemise kind vars that appear free in the kinds of type variables (030cba6)

git at git.haskell.org git at git.haskell.org
Wed Jul 2 16:11:42 UTC 2014


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

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/030cba65c855dfa01ae0dc461029638ed3d7539f/ghc

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

commit 030cba65c855dfa01ae0dc461029638ed3d7539f
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Jun 24 22:23:29 2014 +0100

    In TcValidity.checkAmbiguity, skolemise kind vars that appear free in the kinds of type variables
    
    This was shown up by Trac #9222.
    
    (cherry picked from commit 2be99d2309471bc75ddb9cb47acda9ccbcb7ab63)


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

030cba65c855dfa01ae0dc461029638ed3d7539f
 compiler/typecheck/TcValidity.lhs | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/compiler/typecheck/TcValidity.lhs b/compiler/typecheck/TcValidity.lhs
index d080c08..d85287c 100644
--- a/compiler/typecheck/TcValidity.lhs
+++ b/compiler/typecheck/TcValidity.lhs
@@ -69,11 +69,16 @@ checkAmbiguity ctxt ty
 
   | otherwise
   = do { traceTc "Ambiguity check for" (ppr ty)
-       ; (subst, _tvs) <- tcInstSkolTyVars (varSetElems (tyVarsOfType ty))
+       ; let free_tkvs = varSetElemsKvsFirst (closeOverKinds (tyVarsOfType ty))
+       ; (subst, _tvs) <- tcInstSkolTyVars free_tkvs
        ; let ty' = substTy subst ty
-              -- The type might have free TyVars,
-              -- so we skolemise them as TcTyVars
+              -- The type might have free TyVars, esp when the ambiguity check
+              -- happens during a call to checkValidType,
+              -- so we skolemise them as TcTyVars.
               -- Tiresome; but the type inference engine expects TcTyVars
+              -- NB: The free tyvar might be (a::k), so k is also free
+              --     and we must skolemise it as well. Hence closeOverKinds.
+              --     (Trac #9222)
 
          -- Solve the constraints eagerly because an ambiguous type
          -- can cause a cascade of further errors.  Since the free



More information about the ghc-commits mailing list