From bb4a2ca2a9ef4aa1d7561bb75b24ba6b9d7ac486 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Tue, 16 Jun 2020 21:58:27 +0100 Subject: [PATCH] Always recompile modules with TH splices Tentative fix for #614 TODO support stability --- src/Development/IDE/Core/Compile.hs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Development/IDE/Core/Compile.hs b/src/Development/IDE/Core/Compile.hs index a5770b86d..77013e69c 100644 --- a/src/Development/IDE/Core/Compile.hs +++ b/src/Development/IDE/Core/Compile.hs @@ -582,10 +582,28 @@ loadInterface session ms deps regen = do session' <- foldM (\e d -> liftIO $ loadDepModuleIO (hirModIface d) Nothing e) session deps res <- liftIO $ checkOldIface session' ms SourceUnmodified (Just iface) case res of - (UpToDate, Just x) -> return ([], Just $ HiFileResult ms x) + (UpToDate, Just x) + -- If the module used TH splices when it was last + -- compiled, then the recompilation check is not + -- accurate enough (#481) and we must ignore + -- it. However, if the module is stable (none of + -- the modules it depends on, directly or + -- indirectly, changed), then we *can* skip + -- recompilation. This is why the SourceModified + -- type contains SourceUnmodifiedAndStable, and + -- it's pretty important: otherwise ghc --make + -- would always recompile TH modules, even if + -- nothing at all has changed. Stability is just + -- the same check that make is doing for us in + -- one-shot mode. + | not (mi_used_th iface) || stable + -> return ([], Just $ HiFileResult ms x) _ -> regen Maybes.Failed err -> do let errMsg = showSDoc dflags err dflags = hsc_dflags session diag = diagFromString "interface file loading" DsError (noSpan hiFile) errMsg return (diag, Nothing) + where + -- TODO support stability + stable = False