From f7e8044f26652537e9b87c4481a45cdfb1bafb8a Mon Sep 17 00:00:00 2001 From: simonpj Date: Wed, 2 Nov 2005 09:57:45 +0000 Subject: [PATCH] [project @ 2005-11-02 09:57:45 by simonpj] Correct the TH fix of Oct 26, involving thFAKE MERGE TO STABLE Original message 1) A bug in the renaming of [d| brackets |]. The problem was that when we renamed the bracket we messed up the name cache, because the module was still that of the parent module. Now we set a fake module before renaming it. But we have to tell the *typechecker* too, not just the renamer. See comments with TcSplice.tc_bracket (DecBr case). Should fix TH failures in the STABLE branch --- ghc/compiler/typecheck/TcRnMonad.lhs | 3 +++ ghc/compiler/typecheck/TcSplice.lhs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/typecheck/TcRnMonad.lhs b/ghc/compiler/typecheck/TcRnMonad.lhs index a4032cd..845bdd4 100644 --- a/ghc/compiler/typecheck/TcRnMonad.lhs +++ b/ghc/compiler/typecheck/TcRnMonad.lhs @@ -373,6 +373,9 @@ dumpOptTcRn flag doc = ifOptM flag (dumpTcRn doc) getModule :: TcRn Module getModule = do { env <- getGblEnv; return (tcg_mod env) } +setModule :: Module -> TcRn a -> TcRn a +setModule mod thing_inside = updGblEnv (\env -> env { tcg_mod = mod }) thing_inside + tcIsHsBoot :: TcRn Bool tcIsHsBoot = do { env <- getGblEnv; return (isHsBoot (tcg_src env)) } diff --git a/ghc/compiler/typecheck/TcSplice.lhs b/ghc/compiler/typecheck/TcSplice.lhs index 1262674..37adac1 100644 --- a/ghc/compiler/typecheck/TcSplice.lhs +++ b/ghc/compiler/typecheck/TcSplice.lhs @@ -34,6 +34,7 @@ import TcMType ( newTyFlexiVarTy, newKindVar, UserTypeCtxt(ExprSigCtxt), zonkTc import TcHsType ( tcHsSigType, kcHsType ) import TcIface ( tcImportDecl ) import TypeRep ( Type(..), PredType(..), TyThing(..) ) -- For reification +import PrelNames ( thFAKE ) import Name ( Name, NamedThing(..), nameOccName, nameModule, isExternalName, nameIsLocalOrFrom ) import NameEnv ( lookupNameEnv ) @@ -139,9 +140,13 @@ tc_bracket (TypBr typ) -- Result type is Type (= Q Typ) tc_bracket (DecBr decls) - = do { tcTopSrcDecls emptyModDetails decls + = do { setModule thFAKE $ tcTopSrcDecls emptyModDetails decls -- Typecheck the declarations, dicarding the result -- We'll get all that stuff later, when we splice it in + -- See comments with RnExpr.rnBracket for the thFAKE stuff; + -- the type checker uses the module name to decide which + -- names are local (and hence can be found in the local + -- type envt), so we do need to set the module here too. ; decl_ty <- tcMetaTy decTyConName ; q_ty <- tcMetaTy qTyConName -- 1.7.10.4