[commit: ghc] master: Fix an assertion failure in the stage2 compiler (0d9c2e8)

Simon Peyton Jones simonpj at microsoft.com
Thu May 24 15:05:08 CEST 2012


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/0d9c2e8c6c8781dc5afdb9f2b778c506b09fdfbe

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

commit 0d9c2e8c6c8781dc5afdb9f2b778c506b09fdfbe
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu May 24 12:27:12 2012 +0100

    Fix an assertion failure in the stage2 compiler
    
    Rather an unsavory fix, but will go away when we do the major
    TH reorganisation from my blog post.

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

 compiler/typecheck/TcHsType.lhs |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/compiler/typecheck/TcHsType.lhs b/compiler/typecheck/TcHsType.lhs
index b780c3b..a380882 100644
--- a/compiler/typecheck/TcHsType.lhs
+++ b/compiler/typecheck/TcHsType.lhs
@@ -829,15 +829,24 @@ kindGeneralize tkvs
   = do { gbl_tvs  <- tcGetGlobalTyVars -- Already zonked
        ; tidy_env <- tcInitTidyEnv
        ; tkvs     <- zonkTyVarsAndFV tkvs
-       ; let kvs_to_quantify = varSetElems (tkvs `minusVarSet` gbl_tvs)
+       ; let kvs_to_quantify = filter isKindVar (varSetElems (tkvs `minusVarSet` gbl_tvs))
                 -- Any type varaibles in tkvs will be in scope,
                 -- and hence in gbl_tvs, so after removing gbl_tvs
                 -- we should only have kind variables left
+		--
+ 		-- BUT there is a smelly case (to be fixed when TH is reorganised)
+		--     f t = [| e :: $t |]
+                -- When typechecking the body of the bracket, we typecheck $t to a
+                -- unification variable 'alpha', with no biding forall.  We don't
+                -- want to kind-quantify it!
 
              (_, tidy_kvs_to_quantify) = tidyTyVarBndrs tidy_env kvs_to_quantify
                            -- We do not get a later chance to tidy!
 
        ; ASSERT2 (all isKindVar kvs_to_quantify, ppr kvs_to_quantify $$ ppr tkvs)
+             -- This assertion is obviosy true because of the filter isKindVar
+             -- but we'll remove that when reorganising TH, and then the assertion
+             -- will mean something
          zonkQuantifiedTyVars tidy_kvs_to_quantify }
 \end{code}
 





More information about the Cvs-ghc mailing list