hscParse: do not record a dependency on non-existent source files
authorSimon Marlow <marlowsd@gmail.com>
Fri, 18 Nov 2011 14:59:37 +0000 (14:59 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Fri, 18 Nov 2011 14:59:37 +0000 (14:59 +0000)
compiler/main/HscMain.hs

index b81afdc..4d106bd 100644 (file)
@@ -149,6 +149,7 @@ import Control.Monad
 import Data.Maybe
 import Data.IORef
 import System.FilePath as FilePath
+import System.Directory
 
 #include "HsVersions.h"
 
@@ -365,9 +366,14 @@ hscParse' mod_summary = do
                           Just f  -> filter (/= FilePath.normalise f) srcs0
                           Nothing -> srcs0
 
+            -- sometimes we see source files from earlier
+            -- preprocessing stages that cannot be found, so just
+            -- filter them out:
+            srcs2 <- liftIO $ filterM doesFileExist srcs1
+
             return HsParsedModule {
                       hpm_module    = rdr_module,
-                      hpm_src_files = srcs1
+                      hpm_src_files = srcs2
                    }
 
 -- XXX: should this really be a Maybe X?  Check under which circumstances this