Skip to content

Commit

Permalink
Fix #9122
Browse files Browse the repository at this point in the history
When checking internal version ranges, we need to make sure we
are not mistaking a libraries with the same name but from different
packages. See #9132.
  • Loading branch information
ffaf1 committed Sep 19, 2023
1 parent 50e5940 commit 3b0472f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Cabal/src/Distribution/PackageDescription/Check/Target.hs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ checkBuildInfoPathsContent :: Monad m => BuildInfo -> CheckM m ()
checkBuildInfoPathsContent bi = do
mapM_ checkLang (allLanguages bi)
mapM_ checkExt (allExtensions bi)
mapM_ checkDep (targetBuildDepends bi)
mapM_ checkIntDep (targetBuildDepends bi)
df <- asksCM ccDesugar
-- This way we can use the same function for legacy&non exedeps.
let ds = buildToolDepends bi ++ catMaybes (map df $ buildTools bi)
Expand All @@ -387,8 +387,8 @@ checkBuildInfoPathsContent bi = do
(not . null $ dss)
(PackageDistSuspicious $ DeprecatedExtensions dss)

checkDep :: Monad m => Dependency -> CheckM m ()
checkDep d@(Dependency name vrange _) = do
checkIntDep :: Monad m => Dependency -> CheckM m ()
checkIntDep d@(Dependency name vrange _) = do
mpn <-
asksCM
( packageNameToUnqualComponentName
Expand All @@ -400,7 +400,11 @@ checkBuildInfoPathsContent bi = do
pVer <- asksCM (pkgVersion . pnPackageId . ccNames)
let allLibNs = mpn : lns
when
(packageNameToUnqualComponentName name `elem` allLibNs)
( mpn == packageNameToUnqualComponentName name
-- Make sure it is not a library with the
-- same name from another package.
&& packageNameToUnqualComponentName name `elem` allLibNs
)
( checkP
(not $ pVer `withinRange` vrange)
(PackageBuildImpossible $ ImpossibleInternalDep [d])
Expand Down

0 comments on commit 3b0472f

Please sign in to comment.