summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser
diff options
context:
space:
mode:
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