Skip to content

Commit 3ba3f38

Browse files
authored
ghcide: Only try stating a core file after we ensure it actually exists (#4076)
This doesn't change any behaviour, but ensures we have a more informative error message if we somehow request a linkable that does not exist.
1 parent 908db38 commit 3ba3f38

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: ghcide/src/Development/IDE/Core/Rules.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1116,16 +1116,16 @@ getLinkableRule recorder =
11161116
HiFileResult{hirModIface, hirModDetails, hirCoreFp} <- use_ GetModIface f
11171117
let obj_file = ml_obj_file (ms_location ms)
11181118
core_file = ml_core_file (ms_location ms)
1119-
-- Can't use `GetModificationTime` rule because the core file was possibly written in this
1120-
-- very session, so the results aren't reliable
1121-
core_t <- liftIO $ getModTime core_file
11221119
case hirCoreFp of
1123-
Nothing -> error "called GetLinkable for a file without a linkable"
1120+
Nothing -> error $ "called GetLinkable for a file without a linkable: " ++ show f
11241121
Just (bin_core, fileHash) -> do
11251122
session <- use_ GhcSessionDeps f
11261123
linkableType <- getLinkableType f >>= \case
1127-
Nothing -> error "called GetLinkable for a file which doesn't need compilation"
1124+
Nothing -> error $ "called GetLinkable for a file which doesn't need compilation: " ++ show f
11281125
Just t -> pure t
1126+
-- Can't use `GetModificationTime` rule because the core file was possibly written in this
1127+
-- very session, so the results aren't reliable
1128+
core_t <- liftIO $ getModTime core_file
11291129
(warns, hmi) <- case linkableType of
11301130
-- Bytecode needs to be regenerated from the core file
11311131
BCOLinkable -> liftIO $ coreFileToLinkable linkableType (hscEnv session) ms hirModIface hirModDetails bin_core (posixSecondsToUTCTime core_t)

0 commit comments

Comments
 (0)