summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-07-05 14:16:35 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2021-07-20 10:59:08 +0100
commit71ccf4999d02aead5c518897c73c0b8eb9f6795f (patch)
treea9f28a0abb4a50a316e797f9c81ea95e8022e609 /compiler/GHC/Parser
parent58b960d2af0ebfc37104ec68a4df377a074951dd (diff)
downloadhaskell-wip/t20084.tar.gz
driver: Fix recompilation for modules importing GHC.Primwip/t20084
The GHC.Prim module is quite special as there is no interface file, therefore it doesn't appear in ms_textual_imports, but the ghc-prim package does appear in the direct package dependencies. This confused the recompilation checking which couldn't find any modules from ghc-prim and concluded that the package was no longer a dependency. The fix is to keep track of whether GHC.Prim is imported separately in the relevant places. Fixes #20084
Diffstat (limited to 'compiler/GHC/Parser')
-rw-r--r--compiler/GHC/Parser/Header.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/GHC/Parser/Header.hs b/compiler/GHC/Parser/Header.hs
index 65e09bfeff..68468d89eb 100644
--- a/compiler/GHC/Parser/Header.hs
+++ b/compiler/GHC/Parser/Header.hs
@@ -75,6 +75,7 @@ getImports :: ParserOpts -- ^ Parser options
(Messages PsMessage)
([(Maybe FastString, Located ModuleName)],
[(Maybe FastString, Located ModuleName)],
+ Bool, -- Is GHC.Prim imported or not
Located ModuleName))
-- ^ The source imports and normal imports (with optional package
-- names from -XPackageImports), and the module name.
@@ -100,17 +101,19 @@ getImports popts implicit_prelude buf filename source_filename = do
(src_idecls, ord_idecls) = partition ((== IsBoot) . ideclSource . unLoc) imps
-- GHC.Prim doesn't exist physically, so don't go looking for it.
- ordinary_imps = filter ((/= moduleName gHC_PRIM) . unLoc
- . ideclName . unLoc)
- ord_idecls
+ (ordinary_imps, ghc_prim_import)
+ = partition ((/= moduleName gHC_PRIM) . unLoc
+ . ideclName . unLoc)
+ ord_idecls
implicit_imports = mkPrelImports (unLoc mod) main_loc
implicit_prelude imps
convImport (L _ i) = (fmap sl_fs (ideclPkgQual i), ideclName i)
in
- return (map convImport src_idecls,
- map convImport (implicit_imports ++ ordinary_imps),
- mod)
+ return (map convImport src_idecls
+ , map convImport (implicit_imports ++ ordinary_imps)
+ , not (null ghc_prim_import)
+ , mod)
mkPrelImports :: ModuleName
-> SrcSpan -- Attribute the "import Prelude" to this location