[commit: ghc] master: Fix #7231: don't unload stable modules when there is an error later (086d7c5)

Simon Marlow <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/086d7c54f5bddbc9e5d94a9ae9c4b5aeeab53a35

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

commit 086d7c54f5bddbc9e5d94a9ae9c4b5aeeab53a35
Author: Simon Marlow <[email protected]>
Date:   Tue Nov 27 08:55:31 2012 +0000

    Fix #7231: don't unload stable modules when there is an error later

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

 compiler/main/GhcMake.hs |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index 62ac63f..cc51e05 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -239,11 +239,18 @@ load how_much = do
         stable_mg = 
             [ AcyclicSCC ms
             | AcyclicSCC ms <- full_mg,
-              ms_mod_name ms `elem` stable_obj++stable_bco,
-              ms_mod_name ms `notElem` [ ms_mod_name ms' | 
-                                            AcyclicSCC ms' <- partial_mg ] ]
-
-        mg = stable_mg ++ partial_mg
+              ms_mod_name ms `elem` stable_obj++stable_bco ]
+ 
+        -- the modules from partial_mg that are not also stable
+        -- NB. also keep cycles, we need to emit an error message later
+        unstable_mg = filter not_stable partial_mg
+          where not_stable (CyclicSCC _) = True
+                not_stable (AcyclicSCC ms)
+                   = ms_mod_name ms `notElem` stable_obj++stable_bco
+
+        -- Load all the stable modules first, before attempting to load
+        -- an unstable module (#7231).
+        mg = stable_mg ++ unstable_mg
 
     -- clean up between compilations
     let cleanup hsc_env = intermediateCleanTempFiles dflags
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.