summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-12-22 16:59:53 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-23 10:56:11 -0500
commit80daefce4ec1169ac3ef0552b8600c71527d84c2 (patch)
treef9836356149ccbcdc91b252ee5df7e8e6e5c2f10 /compiler
parent13a6d85a74872f22c8762d04678f7499e7890a5f (diff)
downloadhaskell-80daefce4ec1169ac3ef0552b8600c71527d84c2.tar.gz
Properly filter for module visibility in resolvePackageImport
This completes the fix for #20779 / !7123. Beforehand, the program worked by accident because the two versions of the library happened to be ordered properly (due to how the hashes were computed). In the real world I observed them being the other way around which meant the final lookup failed because we weren't filtering for visibility. I modified the test so that it failed (and it's fixed by this patch).
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Unit/State.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs
index e178bafea6..859b99f1a1 100644
--- a/compiler/GHC/Unit/State.hs
+++ b/compiler/GHC/Unit/State.hs
@@ -551,7 +551,7 @@ searchPackageId pkgstate pid = filter ((pid ==) . unitPackageId)
resolvePackageImport :: UnitState -> ModuleName -> PackageName -> Maybe UnitId
resolvePackageImport unit_st mn pn = do
-- 1. Find all modules providing the ModuleName (this accounts for visibility/thinning etc)
- providers <- Map.lookup mn (moduleNameProvidersMap unit_st)
+ providers <- Map.filter originVisible <$> Map.lookup mn (moduleNameProvidersMap unit_st)
-- 2. Get the UnitIds of the candidates
let candidates_uid = map (toUnitId . moduleUnit) $ Map.keys providers
-- 3. Get the package names of the candidates