Skip to content

Commit d899e53

Browse files
committed
PD check: do not treat library names as package names (#9132)
Fixes #9122 (cherry picked from commit 4aa5f88)
1 parent 529f850 commit d899e53

File tree

7 files changed

+48
-5
lines changed

7 files changed

+48
-5
lines changed

Cabal/src/Distribution/PackageDescription/Check.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,17 +1210,13 @@ checkFields pkg =
12101210
| (compiler, vr) <- testedWith pkg
12111211
, isNoVersion vr ]
12121212

1213-
internalLibraries =
1214-
map (maybe (packageName pkg) unqualComponentNameToPackageName . libraryNameString . libName)
1215-
(allLibraries pkg)
1216-
12171213
internalExecutables = map exeName $ executables pkg
12181214

12191215
internalLibDeps =
12201216
[ dep
12211217
| bi <- allBuildInfo pkg
12221218
, dep@(Dependency name _ _) <- targetBuildDepends bi
1223-
, name `elem` internalLibraries
1219+
, name == packageName pkg
12241220
]
12251221

12261222
internalExeDeps =
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cabal-version: 3.4
2+
name: p
3+
Version: 2
4+
Build-Type: Simple
5+
6+
library
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cabal-version: 3.4
2+
name: q
3+
Version: 1
4+
Build-Type: Simple
5+
6+
library
7+
build-depends: q:p
8+
9+
library p
10+
build-depends: p:p == 2
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Setup configure
2+
Configuring p-2...
3+
# Setup build
4+
Preprocessing library for p-2...
5+
Building library for p-2...
6+
# Setup copy
7+
Installing library in <PATH>
8+
# Setup register
9+
Registering library for p-2...
10+
# Setup configure
11+
Configuring q-1...
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Setup configure
2+
Configuring p-2...
3+
# Setup build
4+
Preprocessing library for p-2...
5+
Building library for p-2...
6+
# Setup copy
7+
Installing library in <PATH>
8+
# Setup register
9+
Registering library for p-2...
10+
# Setup configure
11+
Configuring q-1...
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
main = setupAndCabalTest $ withPackageDb $ do
4+
withDirectory "p" $ setup_install []
5+
withDirectory "q" $ setup "configure" []

changelog.d/issue-9122

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
synopsis: Fix dependency on an external package when an internal library with the same name exists
2+
packages: Cabal
3+
issues: #9122
4+
prs: #9132

0 commit comments

Comments
 (0)