Commit c27ec458 authored by simonpj's avatar simonpj
Browse files

[project @ 2003-10-29 17:04:13 by simonpj]

Declaration splices should shadow the top-level environment
parent ba45de99
......@@ -44,7 +44,6 @@ elemNameEnv :: Name -> NameEnv a -> Bool
unitNameEnv :: Name -> a -> NameEnv a
lookupNameEnv :: NameEnv a -> Name -> Maybe a
lookupNameEnv_NF :: NameEnv a -> Name -> a
mapNameEnv :: (a->b) -> NameEnv a -> NameEnv b
foldNameEnv :: (a -> b -> b) -> b -> NameEnv a -> b
filterNameEnv :: (elt -> Bool) -> NameEnv elt -> NameEnv elt
......@@ -60,7 +59,6 @@ extendNameEnvList= addListToUFM
delFromNameEnv = delFromUFM
delListFromNameEnv = delListFromUFM
elemNameEnv = elemUFM
mapNameEnv = mapUFM
unitNameEnv = unitUFM
filterNameEnv = filterUFM
......
......@@ -18,7 +18,7 @@ module OccName (
-- The OccEnv type
OccEnv, emptyOccEnv, unitOccEnv, extendOccEnv,
lookupOccEnv, mkOccEnv, extendOccEnvList, elemOccEnv,
occEnvElts, foldOccEnv, plusOccEnv_C, extendOccEnv_C,
occEnvElts, foldOccEnv, plusOccEnv, plusOccEnv_C, extendOccEnv_C,
-- The OccSet type
......@@ -281,6 +281,7 @@ elemOccEnv :: OccName -> OccEnv a -> Bool
foldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b
occEnvElts :: OccEnv a -> [a]
extendOccEnv_C :: (a->a->a) -> OccEnv a -> OccName -> a -> OccEnv a
plusOccEnv :: OccEnv a -> OccEnv a -> OccEnv a
plusOccEnv_C :: (a->a->a) -> OccEnv a -> OccEnv a -> OccEnv a
emptyOccEnv = emptyUFM
......@@ -292,6 +293,7 @@ mkOccEnv = listToUFM
elemOccEnv = elemUFM
foldOccEnv = foldUFM
occEnvElts = eltsUFM
plusOccEnv = plusUFM
plusOccEnv_C = plusUFM_C
extendOccEnv_C = addToUFM_C
......
......@@ -483,7 +483,7 @@ instance Ord ImportSpec where
\begin{code}
plusProv :: Provenance -> Provenance -> Provenance
-- Choose LocalDef over Imported
-- There is an obscure bug lurking here, in the presence
-- There is an obscure bug lurking here; in the presence
-- of recursive modules, something can be imported *and* locally
-- defined, and one might refer to it with a qualified name from
-- the import -- but I'm going to ignore that because it makes
......
......@@ -28,7 +28,7 @@ import RdrHsSyn
import RnHsSyn
import TcRnMonad
import RnEnv
import RdrName ( plusGlobalRdrEnv )
import OccName ( plusOccEnv )
import RnNames ( importsFromLocalDecls )
import RnTypes ( rnHsTypeFVs, rnPat, litFVs, rnOverLit, rnPatsAndThen,
dupFieldErr, precParseErr, sectionPrecErr, patSigErr, checkTupSize )
......@@ -637,7 +637,12 @@ rnBracket (DecBr group)
= importsFromLocalDecls group `thenM` \ (rdr_env, avails) ->
-- Discard avails (not useful here)
updGblEnv (\gbl -> gbl { tcg_rdr_env = rdr_env `plusGlobalRdrEnv` tcg_rdr_env gbl }) $
updGblEnv (\gbl -> gbl { tcg_rdr_env = tcg_rdr_env gbl `plusOccEnv` rdr_env}) $
-- Notice plusOccEnv, not plusGlobalRdrEnv. In this situation we want
-- to *shadow* top-level bindings. E.g.
-- foo = 1
-- bar = [d| foo = 1|]
-- So we drop down to plusOccEnv. (Perhaps there should be a fn in RdrName.)
rnSrcDecls group `thenM` \ (tcg_env, group') ->
-- Discard the tcg_env; it contains only extra info about fixity
......
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