Make type-tidying work for coercion variables
authorsimonpj@microsoft.com <unknown>
Mon, 2 Apr 2007 07:38:35 +0000 (07:38 +0000)
committersimonpj@microsoft.com <unknown>
Mon, 2 Apr 2007 07:38:35 +0000 (07:38 +0000)
When tidying a TyVar binder, we must tidy its kind if it's a coercion
variable!  I had forgotten to do this, which is a serious bug.  As a
result some more complicated programs were getting a Lint error when
reading in interface files.  Score one for Core Lint!

compiler/types/Type.lhs

index fd81795..fe70716 100644 (file)
@@ -733,13 +733,17 @@ It doesn't change the uniques at all, just the print names.
 
 \begin{code}
 tidyTyVarBndr :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
 
 \begin{code}
 tidyTyVarBndr :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
-tidyTyVarBndr (tidy_env, subst) tyvar
+tidyTyVarBndr env@(tidy_env, subst) tyvar
   = case tidyOccName tidy_env (getOccName name) of
   = case tidyOccName tidy_env (getOccName name) of
-      (tidy', occ') ->         ((tidy', subst'), tyvar')
-                   where
-                       subst' = extendVarEnv subst tyvar tyvar'
-                       tyvar' = setTyVarName tyvar name'
-                       name'  = tidyNameOcc name occ'
+      (tidy', occ') -> ((tidy', subst'), tyvar'')
+       where
+         subst' = extendVarEnv subst tyvar tyvar''
+         tyvar' = setTyVarName tyvar name'
+         name'  = tidyNameOcc name occ'
+               -- Don't forget to tidy the kind for coercions!
+         tyvar'' | isCoVar tyvar = setTyVarKind tyvar' kind'
+                 | otherwise     = tyvar'
+         kind'  = tidyType env (tyVarKind tyvar)
   where
     name = tyVarName tyvar
 
   where
     name = tyVarName tyvar