[commit: ghc] master: Tiny refactor to tcExtendRecEnv (66ce7de)

git at git.haskell.org git at git.haskell.org
Fri Dec 21 16:55:17 UTC 2018


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

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

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

commit 66ce7de15dbc594e6890b5651dba3aa669c8d5fc
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Dec 20 12:41:14 2018 +0000

    Tiny refactor to tcExtendRecEnv
    
    In tcExtendRecEnv, there is no need to us setGlobalTypeEnv
    (which side-effects the tcg_type_env_var).  tcExtendRecEnv
    is used only when kind-checking a group of type/class decls
    and no knot-tying via tcg_type_env_var is needed.
    
    There is no change in functionality.


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

66ce7de15dbc594e6890b5651dba3aa669c8d5fc
 compiler/typecheck/TcEnv.hs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcEnv.hs b/compiler/typecheck/TcEnv.hs
index d32272b..7337345 100644
--- a/compiler/typecheck/TcEnv.hs
+++ b/compiler/typecheck/TcEnv.hs
@@ -378,8 +378,13 @@ tcExtendRecEnv :: [(Name,TyThing)] -> TcM r -> TcM r
 -- Just like tcExtendGlobalEnv, except the argument is a list of pairs
 tcExtendRecEnv gbl_stuff thing_inside
  = do  { tcg_env <- getGblEnv
-       ; let ge' = extendNameEnvList (tcg_type_env tcg_env) gbl_stuff
-       ; tcg_env' <- setGlobalTypeEnv tcg_env ge'
+       ; let ge'      = extendNameEnvList (tcg_type_env tcg_env) gbl_stuff
+             tcg_env' = tcg_env { tcg_type_env = ge' }
+         -- No need for setGlobalTypeEnv (which side-effects the
+         -- tcg_type_env_var); tcExtendRecEnv is used just
+         -- when kind-check a group of type/class decls. It would
+         -- in any case be wrong for an interface-file decl to end up
+         -- with a TcTyCon in it!
        ; setGblEnv tcg_env' thing_inside }
 
 {-



More information about the ghc-commits mailing list