Commit c9c45479 authored by sewardj's avatar sewardj
Browse files

[project @ 2000-10-16 13:51:28 by sewardj]

push along (RnEnv doesn't typecheck, tho)
parent db4d0890
......@@ -12,16 +12,17 @@ module HscTypes (
WhetherHasOrphans, ImportVersion, ExportItem,
PersistentRenamerState(..), IsBootInterface, Avails, DeclsMap,
IfaceInsts, IfaceRules, DeprecationEnv, OrigNameEnv, AvailEnv,
IfaceInsts, IfaceRules, DeprecationEnv, OrigNameEnv,
AvailEnv, AvailInfo, GenAvailInfo(..),
PersistentCompilerState(..),
InstEnv,
GlobalRdrEnv,
GlobalRdrEnv, RdrAvailInfo,
-- Provenance
Provenance(..), ImportReason(..), PrintUnqualified,
pprProvenance, hasBetterProv
pprNameProvenance, hasBetterProv
) where
......@@ -480,9 +481,9 @@ hasBetterProv (NonLocalDef (UserImport _ _ True) _) _ = True
hasBetterProv (NonLocalDef (UserImport _ _ _ ) _) (NonLocalDef ImplicitImport _) = True
hasBetterProv _ _ = False
pprProvenance :: Name -> Provenance -> SDoc
pprProvenance name LocalDef = ptext SLIT("defined at") <+> ppr (nameSrcLoc name)
pprProvenance name (NonLocalDef why _) = sep [ppr_reason why,
pprNameProvenance :: Name -> Provenance -> SDoc
pprNameProvenance name LocalDef = ptext SLIT("defined at") <+> ppr (nameSrcLoc name)
pprNameProvenance name (NonLocalDef why _) = sep [ppr_reason why,
nest 2 (parens (ppr_defn (nameSrcLoc name)))]
ppr_reason ImplicitImport = ptext SLIT("implicitly imported")
......
......@@ -16,14 +16,17 @@ import RdrName ( RdrName, rdrNameModule, rdrNameOcc, isQual, isUnqual,
mkRdrUnqual, qualifyRdrName
)
import HsTypes ( hsTyVarName, hsTyVarNames, replaceTyVarName )
import HscTypes ( pprNameProvenance )
import HscTypes ( Provenance(..), pprNameProvenance, hasBetterProv,
ImportReason(..), GlobalRdrEnv, Avails, AvailEnv,
AvailInfo, GenAvailInfo(..), RdrAvailInfo )
import RnMonad
import Name ( Name, Provenance(..), ExportFlag(..), NamedThing(..),
ImportReason(..), getSrcLoc,
import Name ( Name, NamedThing(..),
getSrcLoc,
mkLocalName, mkImportedLocalName, mkGlobalName,
mkIPName, hasBetterProv, isLocallyDefined,
nameOccName, setNameModule, nameModule,
extendNameEnv_C, plusNameEnv_C, nameEnvElts
mkIPName, isLocallyDefined,
nameOccName, nameModule,
extendNameEnv_C, plusNameEnv_C, nameEnvElts,
setNameModuleAndLoc
)
import NameSet
import OccName ( OccName, occNameUserString, occNameFlavour )
......@@ -31,7 +34,7 @@ import Module ( ModuleName, moduleName, mkVanillaModule )
import FiniteMap
import Unique ( Unique )
import UniqSupply
import SrcLoc ( SrcLoc )
import SrcLoc ( SrcLoc, noSrcLoc )
import Outputable
import ListSetOps ( removeDups, equivClasses )
import Util ( thenCmp, sortLt )
......@@ -53,7 +56,7 @@ implicitImportProvenance = NonLocalDef ImplicitImport False
newTopBinder :: Module -> RdrName -> SrcLoc -> RnM d Name
newTopBinder mod rdr_name loc
= -- First check the cache
traceRn (text "newTopBinder" <+> ppr mod <+> ppr occ) `thenRn_`
traceRn (text "newTopBinder" <+> ppr mod <+> ppr loc) `thenRn_`
getNameSupplyRn `thenRn` \ (us, cache, ipcache) ->
let
......@@ -220,7 +223,7 @@ lookupGlobalOccRn rdr_name
case lookupRdrEnv global_env rdr_name of
Just [(name,_)] -> returnRn name
Just stuff@(_:_) -> addNameClashErrRn rdr_name stuff `thenRn_`
returnRn name
returnRn rdr_name
Nothing -> -- Not found when processing source code; so fail
failWithRn (mkUnboundName rdr_name)
(unknownNameErr rdr_name)
......@@ -510,7 +513,7 @@ combine_globals ns_old ns_new -- ns_new is often short
is_duplicate :: Provenance -> (Name,Provenance) -> Bool
is_duplicate (n1,LocalDef _) (n2,LocalDef _) = False
is_duplicate _ _ = n1 == n2
is_duplicate n1 n2 = n1 == n2
\end{code}
We treat two bindings of a locally-defined name as a duplicate,
......@@ -686,7 +689,7 @@ warnUnusedModules mods
unused_mod m = vcat [ptext SLIT("Module") <+> quotes (ppr m) <+>
text "is imported, but nothing from it is used",
parens (ptext SLIT("except perhaps to re-export instances visible in") <+>
quotes (pprModuleName m))]
quotes (ppr (moduleName m)))]
warnUnusedImports :: [(Name,Provenance)] -> RnM d ()
warnUnusedImports names
......@@ -696,12 +699,12 @@ warnUnusedImports names
= warnUnusedBinds names
warnUnusedLocalBinds, warnUnusedMatches :: [Name] -> RnM d ()
warnUnusedLocalBinds ns
warnUnusedLocalBinds names
| not opt_WarnUnusedBinds = returnRn ()
| otherwise = warnUnusedBinds [(n,LocalDef) | n<-ns]
| otherwise = warnUnusedBinds [(n,LocalDef) | n<-names]
warnUnusedMatches names
| opt_WarnUnusedMatches = warnUnusedGroup [(n,LocalDef) | n<-ns]
| opt_WarnUnusedMatches = warnUnusedGroup [(n,LocalDef) | n<-names]
| otherwise = returnRn ()
-------------------------
......
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