summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-07-05 14:16:35 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-21 02:45:39 -0400
commit9eb1641e0ef10a7887e794d4d114c9a18a2fd265 (patch)
tree2974508390083775e3bf2c4efcc2113a4c07a2c3 /compiler/GHC/Parser
parentd706fd0432925caf62673a55237a005e22bc4450 (diff)
downloadhaskell-9eb1641e0ef10a7887e794d4d114c9a18a2fd265.tar.gz
driver: Fix recompilation for modules importing GHC.Prim
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