Skip to content

ghcide: Only try stating a core file after we ensure it actually exists #4076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,16 +1116,16 @@ getLinkableRule recorder =
HiFileResult{hirModIface, hirModDetails, hirCoreFp} <- use_ GetModIface f
let obj_file = ml_obj_file (ms_location ms)
core_file = ml_core_file (ms_location ms)
-- Can't use `GetModificationTime` rule because the core file was possibly written in this
-- very session, so the results aren't reliable
core_t <- liftIO $ getModTime core_file
case hirCoreFp of
Nothing -> error "called GetLinkable for a file without a linkable"
Nothing -> error $ "called GetLinkable for a file without a linkable: " ++ show f
Just (bin_core, fileHash) -> do
session <- use_ GhcSessionDeps f
linkableType <- getLinkableType f >>= \case
Nothing -> error "called GetLinkable for a file which doesn't need compilation"
Nothing -> error $ "called GetLinkable for a file which doesn't need compilation: " ++ show f
Just t -> pure t
-- Can't use `GetModificationTime` rule because the core file was possibly written in this
-- very session, so the results aren't reliable
core_t <- liftIO $ getModTime core_file
(warns, hmi) <- case linkableType of
-- Bytecode needs to be regenerated from the core file
BCOLinkable -> liftIO $ coreFileToLinkable linkableType (hscEnv session) ms hirModIface hirModDetails bin_core (posixSecondsToUTCTime core_t)
Expand Down