summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-05-20 12:17:36 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-05-29 10:41:02 -0400
commitfb26d46754564bfacda98618d86d3ee4eda1fcf2 (patch)
tree1aa4bf43107a19ea23fd3bdedd11bed3d77e8778 /compiler
parent5b90e0a173f69c9babb3201f62cd5096798c5240 (diff)
downloadhaskell-fb26d46754564bfacda98618d86d3ee4eda1fcf2.tar.gz
downsweep: Allow TargetFile not to exist when a buffer is given
Currently 'getRootSummary' will fail with an exception if a 'TargetFile' is given but it does not exist even if an input buffer is passed along for this target. In this case it is not necessary for the file to exist since the buffer will be used as input for the compilation pipeline instead of the file anyways.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/main/GhcMake.hs2
-rw-r--r--compiler/main/HscTypes.hs5
2 files changed, 6 insertions, 1 deletions
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index b55a4e3760..3e62558e78 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -1978,7 +1978,7 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots
getRootSummary :: Target -> IO (Either ErrMsg ModSummary)
getRootSummary (Target (TargetFile file mb_phase) obj_allowed maybe_buf)
= do exists <- liftIO $ doesFileExist file
- if exists
+ if exists || isJust maybe_buf
then Right `fmap` summariseFile hsc_env old_summaries file mb_phase
obj_allowed maybe_buf
else return $ Left $ mkPlainErrMsg dflags noSrcSpan $
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 744841a63d..e75b2457f0 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -517,6 +517,11 @@ data Target
--
-- Since GHC version 8.10 modules which require preprocessors such as
-- Literate Haskell or CPP to run are also supported.
+ --
+ -- If a corresponding source file does not exist on disk this will
+ -- result in a 'SourceError' exception if @targetId = TargetModule _@
+ -- is used. However together with @targetId = TargetFile _@ GHC will
+ -- not complain about the file missing.
}
data TargetId