[commit: ghc] master: Kill off the default types in ghc-prim (de5d022)

git at git.haskell.org git at git.haskell.org
Fri May 1 14:42:21 UTC 2015


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

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

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

commit de5d022e1543283effd67c2a03598e2bcaf49930
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri May 1 15:06:00 2015 +0100

    Kill off the default types in ghc-prim
    
    We were trying to load the type for Integer to do defaulting
    in ghc-prim, but it's simply not available at that time.


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

de5d022e1543283effd67c2a03598e2bcaf49930
 compiler/typecheck/TcRnMonad.hs | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcRnMonad.hs b/compiler/typecheck/TcRnMonad.hs
index f3c16cb..f576e33 100644
--- a/compiler/typecheck/TcRnMonad.hs
+++ b/compiler/typecheck/TcRnMonad.hs
@@ -125,7 +125,9 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this
                 tcg_rdr_env        = emptyGlobalRdrEnv,
                 tcg_fix_env        = emptyNameEnv,
                 tcg_field_env      = RecFields emptyNameEnv emptyNameSet,
-                tcg_default        = Nothing,
+                tcg_default        = if modulePackageKey mod == primPackageKey
+                                     then Just []  -- See Note [Default types]
+                                     else Nothing,
                 tcg_type_env       = emptyNameEnv,
                 tcg_type_env_var   = type_env_var,
                 tcg_inst_env       = emptyInstEnv,
@@ -225,7 +227,17 @@ initTcForLookup hsc_env thing_inside
              Nothing -> throwIO $ mkSrcErr $ snd msgs
              Just x -> return x }
 
-{-
+{- Note [Default types]
+~~~~~~~~~~~~~~~~~~~~~~~
+The Integer type is simply not available in package ghc-prim (it is
+declared in integer-gmp).  So we set the defaulting types to (Just
+[]), meaning there are no default types, rather then Nothing, which
+means "use the default default types of Integer, Double".
+
+If you don't do this, attempted defaulting in package ghc-prim causes
+an actual crash (attempting to look up the Integer type).
+
+
 ************************************************************************
 *                                                                      *
                 Initialisation



More information about the ghc-commits mailing list