summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-12-06 11:44:18 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-09 04:27:11 -0500
commit803eefb1109564f4dbabd80721cd45ce7268c4a2 (patch)
treecc7bcc8ece06758953dbae423ed9553b1f0ab156 /ghc
parentaafa5079bd49a55f5c71664ddb95ffcb9d8ca102 (diff)
downloadhaskell-803eefb1109564f4dbabd80721cd45ce7268c4a2.tar.gz
package imports: Take into account package visibility when renaming
In 806e49ae the package imports refactoring code was modified to rename package imports. There was a small oversight which meant the code didn't account for module visibility. This patch fixes that oversight. In general the "lookupPackageName" function is unsafe to use as it doesn't account for package visiblity/thinning/renaming etc, there is just one use in the compiler which would be good to audit. Fixes #20779
Diffstat (limited to 'ghc')
-rw-r--r--ghc/GHCi/UI.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 3a7946bca8..137619100b 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -2199,7 +2199,7 @@ keepPackageImports = filterM is_pkg_import
is_pkg_import :: GHC.GhcMonad m => InteractiveImport -> m Bool
is_pkg_import (IIModule _) = return False
is_pkg_import (IIDecl d)
- = do pkgqual <- GHC.renameRawPkgQualM (ideclPkgQual d)
+ = do pkgqual <- GHC.renameRawPkgQualM (unLoc $ ideclName d) (ideclPkgQual d)
e <- MC.try $ GHC.findQualifiedModule pkgqual mod_name
case e :: Either SomeException Module of
Left _ -> return False
@@ -2555,7 +2555,7 @@ guessCurrentModule cmd
case (head imports) of
IIModule m -> GHC.findQualifiedModule NoPkgQual m
IIDecl d -> do
- pkgqual <- GHC.renameRawPkgQualM (ideclPkgQual d)
+ pkgqual <- GHC.renameRawPkgQualM (unLoc $ ideclName d) (ideclPkgQual d)
GHC.findQualifiedModule pkgqual (unLoc (ideclName d))
-- without bang, show items in context of their parents and omit children
@@ -2752,7 +2752,7 @@ checkAdd ii = do
IIDecl d -> do
let modname = unLoc (ideclName d)
- pkgqual <- GHC.renameRawPkgQualM (ideclPkgQual d)
+ pkgqual <- GHC.renameRawPkgQualM modname (ideclPkgQual d)
m <- GHC.lookupQualifiedModule pkgqual modname
when safe $ do
t <- GHC.isModuleTrusted m