summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2010-06-15 07:06:26 +0000
committersimonpj@microsoft.com <unknown>2010-06-15 07:06:26 +0000
commit0c41772cba7ec3f558cd2619716c7db771eae935 (patch)
tree2cd13daa798e11c728bb97b4c7539b80e8ac871a
parent617a845f9574185f71db0cad7cfcb2e54fcb9db4 (diff)
downloadhaskell-0c41772cba7ec3f558cd2619716c7db771eae935.tar.gz
Fix Trac #4127: build GlobalRdrEnv in GHCi correctly
GHCi was building its GlobalRdrEnv wrongly, so that the gre_par field was bogus. That in turn fooled the renamer. The fix is easy: use the right function! Namely, call RnNames.gresFromAvail rather than availsToNameSet.
-rw-r--r--compiler/main/GHC.hs2
-rw-r--r--compiler/main/InteractiveEval.hs34
-rw-r--r--compiler/rename/RnNames.lhs3
3 files changed, 18 insertions, 21 deletions
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index f5320613ff..e5cfffec93 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -2432,7 +2432,7 @@ getPackageModuleInfo hsc_env mdl = do
return (Just (ModuleInfo {
minf_type_env = mkTypeEnv tys,
minf_exports = names,
- minf_rdr_env = Just $! nameSetToGlobalRdrEnv names (moduleName mdl),
+ minf_rdr_env = Just $! availsToGlobalRdrEnv (moduleName mdl) avails,
minf_instances = error "getModuleInfo: instances for package module unimplemented",
minf_modBreaks = emptyModBreaks
}))
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs
index 38f0998207..7e4406e61b 100644
--- a/compiler/main/InteractiveEval.hs
+++ b/compiler/main/InteractiveEval.hs
@@ -18,7 +18,7 @@ module InteractiveEval (
getHistoryModule,
back, forward,
setContext, getContext,
- nameSetToGlobalRdrEnv,
+ availsToGlobalRdrEnv,
getNamesInScope,
getRdrNamesInScope,
moduleIsInterpreted,
@@ -42,6 +42,7 @@ module InteractiveEval (
import HscMain hiding (compileExpr)
import HscTypes
import TcRnDriver
+import RnNames ( gresFromAvails )
import InstEnv
import Type
import TcType hiding( typeKind )
@@ -807,25 +808,20 @@ setContext toplev_mods export_mods = do
-- Make a GlobalRdrEnv based on the exports of the modules only.
mkExportEnv :: HscEnv -> [Module] -> IO GlobalRdrEnv
-mkExportEnv hsc_env mods = do
- stuff <- mapM (getModuleExports hsc_env) mods
- let
- (_msgs, mb_name_sets) = unzip stuff
- gres = [ nameSetToGlobalRdrEnv (availsToNameSet avails) (moduleName mod)
- | (Just avails, mod) <- zip mb_name_sets mods ]
- --
- return $! foldr plusGlobalRdrEnv emptyGlobalRdrEnv gres
-
-nameSetToGlobalRdrEnv :: NameSet -> ModuleName -> GlobalRdrEnv
-nameSetToGlobalRdrEnv names mod =
- mkGlobalRdrEnv [ GRE { gre_name = name, gre_par = NoParent, gre_prov = vanillaProv mod }
- | name <- nameSetToList names ]
-
-vanillaProv :: ModuleName -> Provenance
--- We're building a GlobalRdrEnv as if the user imported
--- all the specified modules into the global interactive module
-vanillaProv mod_name = Imported [ImpSpec { is_decl = decl, is_item = ImpAll}]
+mkExportEnv hsc_env mods
+ = do { stuff <- mapM (getModuleExports hsc_env) mods
+ ; let (_msgs, mb_name_sets) = unzip stuff
+ envs = [ availsToGlobalRdrEnv (moduleName mod) avails
+ | (Just avails, mod) <- zip mb_name_sets mods ]
+ ; return $! foldr plusGlobalRdrEnv emptyGlobalRdrEnv envs }
+
+availsToGlobalRdrEnv :: ModuleName -> [AvailInfo] -> GlobalRdrEnv
+availsToGlobalRdrEnv mod_name avails
+ = mkGlobalRdrEnv (gresFromAvails imp_prov avails)
where
+ -- We're building a GlobalRdrEnv as if the user imported
+ -- all the specified modules into the global interactive module
+ imp_prov = Imported [ImpSpec { is_decl = decl, is_item = ImpAll}]
decl = ImpDeclSpec { is_mod = mod_name, is_as = mod_name,
is_qual = False,
is_dloc = srcLocSpan interactiveSrcLoc }
diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs
index 9fcfd2877f..9e163738f2 100644
--- a/compiler/rename/RnNames.lhs
+++ b/compiler/rename/RnNames.lhs
@@ -6,7 +6,8 @@
\begin{code}
module RnNames (
rnImports, getLocalNonValBinders,
- rnExports, extendGlobalRdrEnvRn,
+ rnExports, extendGlobalRdrEnvRn,
+ gresFromAvails,
reportUnusedNames, finishWarnings,
) where