From a92a7502797818f8d0823b3e3b37147c14bd9cb9 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Tue, 10 Oct 2006 14:31:45 +0000 Subject: [PATCH] Fail more informatively when a global isn't in the type environment --- compiler/typecheck/TcEnv.lhs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/compiler/typecheck/TcEnv.lhs b/compiler/typecheck/TcEnv.lhs index 6799653..fcf41e5 100644 --- a/compiler/typecheck/TcEnv.lhs +++ b/compiler/typecheck/TcEnv.lhs @@ -66,8 +66,7 @@ import InstEnv ( Instance, DFunId, instanceDFunId, instanceHead ) import DataCon ( DataCon ) import TyCon ( TyCon ) import Class ( Class ) -import Name ( Name, NamedThing(..), getSrcLoc, nameModule, - nameOccName ) +import Name ( Name, NamedThing(..), getSrcLoc, nameModule_maybe, nameOccName ) import PrelNames ( thFAKE ) import NameEnv import OccName ( mkDFunOcc, occNameString, mkInstTyTcOcc ) @@ -114,13 +113,15 @@ tcLookupGlobal name Nothing -> do -- Should it have been in the local envt? - { let mod = nameModule name - ; if mod == tcg_mod env || mod == thFAKE then - notFound name -- It should be local, so panic - -- The thFAKE possibility is because it - -- might be in a declaration bracket - else - tcImportDecl name -- Go find it in an interface + { case nameModule_maybe name of + Nothing -> notFound name -- Internal names can happen in GHCi + + Just mod | mod == tcg_mod env -- Names from this module + -> notFound name -- should be in tcg_type_env + | mod == thFAKE -- Names bound in TH declaration brackets + -> notFound name -- should be in tcg_env + | otherwise + -> tcImportDecl name -- Go find it in an interface }}}}} tcLookupField :: Name -> TcM Id -- Returns the selector Id -- 1.7.10.4