From f671d4250a16dbeed65c97e35b4e29e3cce0c2b1 Mon Sep 17 00:00:00 2001 From: Francesco Ariis Date: Tue, 25 Jul 2023 09:23:36 +0200 Subject: [PATCH] Fix #9122 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. --- .../Distribution/PackageDescription/Check/Target.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Cabal/src/Distribution/PackageDescription/Check/Target.hs b/Cabal/src/Distribution/PackageDescription/Check/Target.hs index 9505dc4d57d..f3cb7d3d8c1 100644 --- a/Cabal/src/Distribution/PackageDescription/Check/Target.hs +++ b/Cabal/src/Distribution/PackageDescription/Check/Target.hs @@ -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) @@ -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 @@ -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])