Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Shayne Fletcher
Glasgow Haskell Compiler
Commits
88c65644
Commit
88c65644
authored
May 03, 2007
by
Simon Marlow
Browse files
cancel out some reverses by changing the order of ic_tmp_ids
parent
e546aeee
Changes
3
Hide whitespace changes
Inline
Side-by-side
compiler/main/GHC.hs
View file @
88c65644
...
...
@@ -231,6 +231,8 @@ import SysTools ( initSysTools, cleanTempFiles, cleanTempFilesExcept,
cleanTempDirs
)
import
Module
import
UniqFM
import
UniqSet
import
Unique
import
PackageConfig
import
FiniteMap
import
Panic
...
...
@@ -1748,10 +1750,14 @@ getBindings s = withSession s $ \hsc_env ->
-- we have to implement the shadowing behaviour of ic_tmp_ids here
-- (see InteractiveContext) and the quickest way is to use an OccEnv.
let
tmp_ids
=
reverse
(
ic_tmp_ids
(
hsc_IC
hsc_env
))
env
=
mkOccEnv
[
(
nameOccName
(
idName
id
),
id
)
|
id
<-
tmp_ids
]
tmp_ids
=
ic_tmp_ids
(
hsc_IC
hsc_env
)
filtered
=
foldr
f
(
const
[]
)
tmp_ids
emptyUniqSet
f
id
rest
set
|
uniq
`
elementOfUniqSet
`
set
=
rest
set
|
otherwise
=
AnId
id
:
rest
(
addOneToUniqSet
set
uniq
)
where
uniq
=
getUnique
(
nameOccName
(
idName
id
))
in
return
(
map
AnId
(
occEnvElts
env
))
return
filtered
getPrintUnqual
::
Session
->
IO
PrintUnqualified
getPrintUnqual
s
=
withSession
s
(
return
.
icPrintUnqual
.
hsc_IC
)
...
...
compiler/main/HscTypes.lhs
View file @
88c65644
...
...
@@ -623,8 +623,8 @@ data InteractiveContext
-- ic_toplev_scope and ic_exports
ic_tmp_ids :: [Id], -- Names bound during interaction.
--
Earli
er Ids shadow
--
lat
er ones with the same OccName.
--
Lat
er Ids shadow
--
earli
er ones with the same OccName.
ic_tyvars :: TyVarSet -- skolem type variables free in
-- ic_tmp_ids. These arise at
...
...
@@ -659,7 +659,9 @@ extendInteractiveContext
-> TyVarSet
-> InteractiveContext
extendInteractiveContext ictxt ids tyvars
= ictxt { ic_tmp_ids = ids ++ ic_tmp_ids ictxt,
= ictxt { ic_tmp_ids = ic_tmp_ids ictxt ++ ids,
-- NB. must be this way around, because we want
-- new ids to shadow existing bindings.
ic_tyvars = ic_tyvars ictxt `unionVarSet` tyvars }
\end{code}
...
...
compiler/typecheck/TcRnDriver.lhs
View file @
88c65644
...
...
@@ -832,7 +832,7 @@ setInteractiveContext hsc_env icxt thing_inside
tcg_inst_env = extendInstEnvList (tcg_inst_env env) dfuns }) $
tcExtendIdEnv
(reverse
(ic_tmp_ids icxt)
)
$
tcExtendIdEnv (ic_tmp_ids icxt) $
-- tcExtendIdEnv does lots:
-- - it extends the local type env (tcl_env) with the given Ids,
-- - it extends the local rdr env (tcl_rdr) with the Names from
...
...
@@ -840,9 +840,8 @@ setInteractiveContext hsc_env icxt thing_inside
-- - it adds the free tyvars of the Ids to the tcl_tyvars
-- set.
--
-- earlier ids in ic_tmp_ids must shadow later ones with the same
-- OccName, but tcExtendIdEnv has the opposite behaviour, hence the
-- reverse above.
-- later ids in ic_tmp_ids must shadow earlier ones with the same
-- OccName, and tcExtendIdEnv implements this behaviour.
do { traceTc (text "setIC" <+> ppr (ic_tmp_ids icxt))
; thing_inside }
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment