Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.

Commit 743792e

Browse files
committed
Clarify modification time comparisons for .hi and .hie files
Addresses #591
1 parent e7d5f16 commit 743792e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/Development/IDE/Core/Rules.hs

+10-5
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ getHomeHieFile f = do
142142
mbHieTimestamp <- use GetModificationTime normal_hie_f
143143
srcTimestamp <- use_ GetModificationTime f
144144

145-
let isUpToDate
146-
| Just d <- mbHieTimestamp = comparing modificationTime d srcTimestamp == GT
147-
| otherwise = False
145+
let isUpToDate = case (modificationTime <$> mbHieTimestamp, modificationTime srcTimestamp) of
146+
-- If the src file is in VFS, then we know it must have been typechecked
147+
-- by now (due to kick) and therefore its .hie file is up to date
148+
(Just _, Nothing) -> True
149+
(Just (Just a), Just b) -> a >= b
150+
_ -> False
148151

149152
unless isUpToDate $
150153
void $ use_ TypeCheck f
@@ -555,8 +558,8 @@ getHiFileRule = defineEarlyCutoff $ \GetHiFile f -> do
555558
Just deps -> do
556559
mbHiVersion <- use GetModificationTime hiFile
557560
modVersion <- use_ GetModificationTime f
558-
case mbHiVersion of
559-
Just hiVersion
561+
case (mbHiVersion, modVersion) of
562+
(Just hiVersion, ModificationTime{})
560563
| modificationTime hiVersion >= modificationTime modVersion -> do
561564
session <- hscEnv <$> use_ GhcSession f
562565
r <- liftIO $ loadInterface session ms deps
@@ -567,6 +570,8 @@ getHiFileRule = defineEarlyCutoff $ \GetHiFile f -> do
567570
Left err -> do
568571
let diag = ideErrorWithSource (Just "interface file loading") (Just DsError) f . T.pack $ err
569572
return (Nothing, (pure diag, Nothing))
573+
(_, VFSVersion{}) ->
574+
error "internal error - GetHiFile of file of interest"
570575
_ ->
571576
pure (Nothing, ([], Nothing))
572577

0 commit comments

Comments
 (0)