Open fgaz opened 2 weeks ago
The error is introduced by this function
257 -- See Note [Dependencies on sublibraries] in Distribution.PackageDescription.Parsec
258 --
259 preProcessInternalDeps :: CabalSpecVersion -> GenericPackageDescription -> GenericPackageDescription
260 preProcessInternalDeps specVer gpd
261 | specVer >= CabalSpecV3_4 = gpd
262 | otherwise = transformAllBuildInfos transformBI transformSBI gpd
263 where
264 transformBI :: BuildInfo -> BuildInfo
265 transformBI =
266 over L.targetBuildDepends (concatMap transformD)
267 . over L.mixins (map transformM)
268
269 transformSBI :: SetupBuildInfo -> SetupBuildInfo
270 transformSBI = over L.setupDepends (concatMap transformD)
271
272 transformD :: Dependency -> [Dependency]
273 transformD (Dependency pn vr ln)
274 | pn == thisPn =
275 if LMainLibName `NES.member` ln
276 then Dependency thisPn vr mainLibSet : sublibs
277 else sublibs
278 where
279 sublibs =
280 [ Dependency (unqualComponentNameToPackageName uqn) vr mainLibSet
281 | LSubLibName uqn <- NES.toList ln
282 ]
283 transformD d = [d]
284
285 transformM :: Mixin -> Mixin
286 transformM (Mixin pn (LSubLibName uqn) inc)
287 | pn == thisPn =
288 mkMixin (unqualComponentNameToPackageName uqn) LMainLibName inc
289 transformM m = m
290
291 thisPn :: PackageName
292 thisPn = pkgName (package (packageDescription gpd))
Setting the cabal-version
to 3.4 resolves the roundtripping error (see first clause in preProcessInternalDeps).
Minimised reproducer:
cabal-version: 3.0
name: io-classes
version: 1.6.0.0
library
library io-classes-mtl
build-depends: io-classes:{io-classes,si-timers}
It seems a bit baffling to me that preProcessInternalDeps
is called only before pretty printing. I think this code can probably be deleted. It seems that is used to be called in more places.
Do you want me to publish a revision which is using cabal-version: 3.4
? Or maybe you don't want me to do that before you have a general fix?
@coot At this point it doesn't matter what you do as the cabal file which exposes the bug is in the index tarball and will never be deleted. (Not a problem, it was a real bug which was exposed by the package)
Originally posted by @mpickering in https://github.com/haskell/cabal/issues/10277#issuecomment-2312199548