Commit 95d8fef4 authored by simonmar's avatar simonmar
Browse files

[project @ 2001-01-18 11:16:08 by simonmar]

When constructing a GlobalRdrEnv from an interface file for use from
the GHCi command line, don't export the qualified names: a module
which happens to export f from module M shouldn't bring into scope the
qualified identifier M.f when we use it from the command line.
parent f81c9189
......@@ -493,13 +493,14 @@ checkDupNames doc_str rdr_names_w_loc
\begin{code}
mkGlobalRdrEnv :: ModuleName -- Imported module (after doing the "as M" name change)
-> Bool -- True <=> want unqualified import
-> Bool -- True <=> want qualified import
-> [AvailInfo] -- What's to be hidden (but only the unqualified
-- version is hidden)
-> (Name -> Provenance)
-> Avails -- Whats imported and how
-> GlobalRdrEnv
mkGlobalRdrEnv this_mod unqual_imp hides mk_provenance avails
mkGlobalRdrEnv this_mod unqual_imp qual_imp hides mk_provenance avails
= gbl_env2
where
-- Make the name environment. We're talking about a
......@@ -517,11 +518,14 @@ mkGlobalRdrEnv this_mod unqual_imp hides mk_provenance avails
add_avail env avail = foldl add_name env (availNames avail)
add_name env name
| unqual_imp = env2
| otherwise = env1
| qual_imp && unqual_imp = env3
| unqual_imp = env2
| qual_imp = env1
| otherwise = env
where
env1 = addOneToGlobalRdrEnv env (mkRdrQual this_mod occ) (name,prov)
env2 = addOneToGlobalRdrEnv env1 (mkRdrUnqual occ) (name,prov)
env2 = addOneToGlobalRdrEnv env (mkRdrUnqual occ) (name,prov)
env3 = addOneToGlobalRdrEnv env1 (mkRdrUnqual occ) (name,prov)
occ = nameOccName name
prov = mk_provenance name
......@@ -537,7 +541,7 @@ mkIfaceGlobalRdrEnv :: [(ModuleName,Avails)] -> GlobalRdrEnv
mkIfaceGlobalRdrEnv m_avails
= foldl add emptyRdrEnv m_avails
where
add env (mod,avails) = plusGlobalRdrEnv env (mkGlobalRdrEnv mod True [] (\n -> LocalDef) avails)
add env (mod,avails) = plusGlobalRdrEnv env (mkGlobalRdrEnv mod True False [] (\n -> LocalDef) avails)
\end{code}
\begin{code}
......
......@@ -164,8 +164,8 @@ importsFromImportDecl this_mod_name (ImportDecl imp_mod_name from qual_only as_m
Just another_name -> another_name
mk_prov name = NonLocalDef (UserImport imp_mod iloc (name `elemNameSet` explicits))
gbl_env = mkGlobalRdrEnv qual_mod unqual_imp hides mk_prov filtered_avails
exports = mkExportAvails qual_mod unqual_imp gbl_env filtered_avails
gbl_env = mkGlobalRdrEnv qual_mod unqual_imp True hides mk_prov filtered_avails
exports = mkExportAvails qual_mod unqual_imp gbl_env filtered_avails
in
returnRn (gbl_env, exports)
\end{code}
......@@ -195,8 +195,8 @@ importsFromLocalDecls this_mod decls
unqual_imp = True -- Want unqualified names
mk_prov n = LocalDef -- Provenance is local
hides = [] -- Hide nothing
gbl_env = mkGlobalRdrEnv mod_name unqual_imp hides mk_prov avails
exports = mkExportAvails mod_name unqual_imp gbl_env avails
gbl_env = mkGlobalRdrEnv mod_name unqual_imp True hides mk_prov avails
exports = mkExportAvails mod_name unqual_imp gbl_env avails
in
returnRn (gbl_env, exports)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment