From: simonpj Date: Wed, 9 Oct 2002 16:28:57 +0000 (+0000) Subject: [project @ 2002-10-09 16:28:56 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~1579 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=e2bcc01c862ab0c4a12040172429075aa5921b49;p=ghc-hetmet.git [project @ 2002-10-09 16:28:56 by simonpj] Fix and simplify renamer warnings about export lists --- diff --git a/ghc/compiler/rename/RnNames.lhs b/ghc/compiler/rename/RnNames.lhs index f1c7992..5877872 100644 --- a/ghc/compiler/rename/RnNames.lhs +++ b/ghc/compiler/rename/RnNames.lhs @@ -180,7 +180,7 @@ importsFromImportDecl this_mod_name mk_prov name = NonLocalDef (UserImport imp_mod iloc (name `elemNameSet` explicits)) gbl_env = mkGlobalRdrEnv qual_mod unqual_imp mk_prov filtered_avails deprecs - imports = mkImportAvails qual_mod unqual_imp gbl_env filtered_avails + imports = mkImportAvails qual_mod unqual_imp filtered_avails in returnM (gbl_env, imports { imp_mods = dir_imp}) } @@ -241,9 +241,9 @@ importsFromLocalDecls group -- Optimisation: filter out names for built-in syntax -- They just clutter up the environment (esp tuples), and the parser -- will generate Exact RdrNames for them, so the cluttered - -- envt is no use. To avoid doing this filter all the type, + -- envt is no use. To avoid doing this filter all the time, -- we use -fno-implicit-prelude as a clue that the filter is - -- worth while. Really, it's only useful for Base and Tuple. + -- worth while. Really, it's only useful for GHC.Base and GHC.Tuple. -- -- It's worth doing because it makes the environment smaller for -- every module that imports the Prelude @@ -255,7 +255,7 @@ importsFromLocalDecls group -- but that stops them being Exact, so they get looked up. Sigh. -- It doesn't matter because it only affects the Data.Tuple really. -- The important thing is to trim down the exports. - imports = mkImportAvails mod_name unqual_imp gbl_env avails' + imports = mkImportAvails mod_name unqual_imp avails' avails' | implicit_prelude = filter not_built_in_syntax avails | otherwise = avails not_built_in_syntax a = not (all isBuiltInSyntaxName (availNames a)) @@ -513,12 +513,14 @@ exports_from_avail export_items warn_dup_exports = case lookupModuleEnvByName mod_avail_env mod of Nothing -> addErr (modExportErr mod) `thenM_` returnM acc - Just mod_avails - -> foldlM (check_occs warn_dup_exports ie) - occs mod_avails `thenM` \ occs' -> - let + Just avail_env + -> let + mod_avails = availEnvElts avail_env avails' = foldl addAvail avails mod_avails in + foldlM (check_occs warn_dup_exports ie) + occs mod_avails `thenM` \ occs' -> + returnM (mod:mods, occs', avails') exports_from_item acc@(mods, occs, avails) ie diff --git a/ghc/compiler/typecheck/TcRnTypes.lhs b/ghc/compiler/typecheck/TcRnTypes.lhs index 81909bf..2a3ca22 100644 --- a/ghc/compiler/typecheck/TcRnTypes.lhs +++ b/ghc/compiler/typecheck/TcRnTypes.lhs @@ -48,7 +48,7 @@ import RnHsSyn ( RenamedHsExpr, RenamedPat, RenamedArithSeqInfo ) import HscTypes ( GhciMode, ExternalPackageState, HomePackageTable, NameCache, GlobalRdrEnv, LocalRdrEnv, FixityEnv, TypeEnv, TyThing, Avails, GenAvailInfo(..), AvailInfo, availName, - IsBootInterface, Deprecations, unQualInScope ) + IsBootInterface, Deprecations ) import TcType ( TcTyVarSet, TcType, TcTauType, TcThetaType, TcPredType, TcKind, tcCmpPred, tcCmpType, tcCmpTypes ) import InstEnv ( DFunId, InstEnv ) @@ -468,13 +468,13 @@ data ImportAvails -- i.e. *excluding* class ops and constructors -- (which appear inside their parent AvailTC) - imp_unqual :: ModuleEnv Avails, + imp_unqual :: ModuleEnv AvailEnv, -- Used to figure out "module M" export specifiers -- Domain is only modules with *unqualified* imports -- (see 1.4 Report Section 5.1.1) - -- The list of Avails is cumulative, not necessarily - -- nicely uniquified. For example, we might have Maybe(Nothing) - -- and Maybe(Just) in the list, separately. + -- We keep the stuff as an AvailEnv so that it's easy to + -- combine stuff coming from different (unqualified) + -- imports of the same module imp_mods :: ModuleEnv (Module, Bool) -- Domain is all directly-imported modules @@ -499,12 +499,12 @@ plusImportAvails (ImportAvails { imp_env = env1, imp_unqual = unqual1, imp_mods = mods1 }) (ImportAvails { imp_env = env2, imp_unqual = unqual2, imp_mods = mods2 }) = ImportAvails { imp_env = env1 `plusAvailEnv` env2, - imp_unqual = plusModuleEnv_C (++) unqual1 unqual2, + imp_unqual = plusModuleEnv_C plusAvailEnv unqual1 unqual2, imp_mods = mods1 `plusModuleEnv` mods2 } mkImportAvails :: ModuleName -> Bool - -> GlobalRdrEnv -> [AvailInfo] -> ImportAvails -mkImportAvails mod_name unqual_imp gbl_env avails + -> [AvailInfo] -> ImportAvails +mkImportAvails mod_name unqual_imp avails = ImportAvails { imp_unqual = mod_avail_env, imp_env = entity_avail_env, imp_mods = emptyModuleEnv }-- Stays empty for module being compiled; @@ -517,8 +517,8 @@ mkImportAvails mod_name unqual_imp gbl_env avails -- module M ( module P ) where ... -- Then we must export whatever came from P unqualified. - unqual_avails | not unqual_imp = [] -- Short cut when no unqualified imports - | otherwise = pruneAvails (unQualInScope gbl_env) avails + unqual_avails | not unqual_imp = emptyAvailEnv -- Qualified import + | otherwise = entity_avail_env -- Unqualified import entity_avail_env = foldl insert emptyAvailEnv avails insert env avail = extendNameEnv_C plusAvail env (availName avail) avail