Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : ghc-7.4

http://hackage.haskell.org/trac/ghc/changeset/1ddd4b3baf0cb592b8ada88fa3ab386c56489b56

>---------------------------------------------------------------

commit 1ddd4b3baf0cb592b8ada88fa3ab386c56489b56
Author: Simon Marlow <[email protected]>
Date:   Fri Mar 2 11:57:32 2012 +0000

    Fix crash caused by allowing duplicate *-modules in the context (#5904)
    
    MERGED from commit 0bc6055bdc140b35c563c0fc9a7a1b2ca92494cc

>---------------------------------------------------------------

 ghc/InteractiveUI.hs |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 139e841..1e1ac64 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -1289,7 +1289,7 @@ setContextKeepingPackageModules keep_ctx transient_ctx = 
do
   new_rem_ctx <- if keep_ctx then return rem_ctx
                              else keepPackageImports rem_ctx
   setGHCiState st{ remembered_ctx = new_rem_ctx,
-                   transient_ctx  = transient_ctx }
+                   transient_ctx  = filterSubsumed new_rem_ctx transient_ctx }
   setGHCContextFromGHCiState
 
 
@@ -1628,7 +1628,10 @@ addImportToContext str = do
   idecl <- GHC.parseImportDecl str
   _ <- GHC.lookupModule (unLoc (ideclName idecl)) Nothing  -- #5836
   modifyGHCiState $ \st ->
-     st { remembered_ctx = addNotSubsumed (IIDecl idecl) (remembered_ctx st) }
+     st { remembered_ctx = addNotSubsumed (IIDecl idecl) (remembered_ctx st)
+        , transient_ctx = filter (not . ((IIDecl idecl) `iiSubsumes`))
+                                 (transient_ctx st)
+        }
   setGHCContextFromGHCiState
 
 setContext :: [String] -> [String] -> GHCi ()
@@ -1683,6 +1686,8 @@ setGHCContext iidecls = GHC.setContext (iidecls ++ prel)
 
 -- | Returns True if the left import subsumes the right one.  Doesn't
 -- need to be 100% accurate, conservatively returning False is fine.
+-- (EXCEPT: (IIModule m) *must* subsume itself, otherwise a panic in
+-- plusProv will ensue (#5904))
 --
 -- Note that an IIModule does not necessarily subsume an IIDecl,
 -- because e.g. a module might export a name that is only available
@@ -1720,6 +1725,12 @@ addNotSubsumed i is
   | any (`iiSubsumes` i) is = is
   | otherwise               = i : filter (not . (i `iiSubsumes`)) is
 
+-- | @filterSubsumed is js@ returns the elements of @js@ not subsumed
+-- by any of @is@.
+filterSubsumed :: [InteractiveImport] -> [InteractiveImport]
+               -> [InteractiveImport]
+filterSubsumed is js = filter (\j -> not (any (`iiSubsumes` j) is)) js
+
 ----------------------------------------------------------------------------
 -- :set
 



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to