Skip to content

Commit

Permalink
Fix #5846, space after multilib
Browse files Browse the repository at this point in the history
This is OK to include in 3.0 release, as I consider this a bug
in initial release. We don't yet need to do heavy lifting as with mixins.
  • Loading branch information
phadej committed Nov 28, 2019
1 parent e39b890 commit e6b479a
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ extra-source-files:
tests/ParserTests/regressions/issue-5055.cabal
tests/ParserTests/regressions/issue-5055.expr
tests/ParserTests/regressions/issue-5055.format
tests/ParserTests/regressions/issue-5846.cabal
tests/ParserTests/regressions/issue-5846.expr
tests/ParserTests/regressions/issue-5846.format
tests/ParserTests/regressions/issue-774.cabal
tests/ParserTests/regressions/issue-774.check
tests/ParserTests/regressions/issue-774.expr
Expand Down
13 changes: 9 additions & 4 deletions Cabal/Distribution/Types/Dependency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,17 @@ instance Parsec Dependency where
$ (char ':' *> spaces *>)
$ versionGuardMultilibs
$ pure <$> parseLib name <|> parseMultipleLibs name

spaces -- https://github.com/haskell/cabal/issues/5846

ver <- parsec <|> pure anyVersion
return $ Dependency name ver $ Set.fromList libs
where makeLib pn ln | unPackageName pn == ln = LMainLibName
| otherwise = LSubLibName $ mkUnqualComponentName ln
parseLib pn = makeLib pn <$> parsecUnqualComponentName
parseMultipleLibs pn = between (char '{' *> spaces)
where
makeLib pn ln
| unPackageName pn == ln = LMainLibName
| otherwise = LSubLibName $ mkUnqualComponentName ln
parseLib pn = makeLib pn <$> parsecUnqualComponentName
parseMultipleLibs pn = between (char '{' *> spaces)
(spaces <* char '}')
$ parsecCommaList $ parseLib pn

Expand Down
1 change: 1 addition & 0 deletions Cabal/tests/ParserTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ regressionTests = testGroup "regressions"
, regressionTest "mixin-3.cabal"
, regressionTest "libpq1.cabal"
, regressionTest "libpq2.cabal"
, regressionTest "issue-5846.cabal"
, regressionTest "indentation.cabal"
, regressionTest "indentation2.cabal"
, regressionTest "indentation3.cabal"
Expand Down
11 changes: 11 additions & 0 deletions Cabal/tests/ParserTests/regressions/issue-5846.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cabal-version: 3.0
name: issue
version: 5846

library
default-language: Haskell2010
build-depends: lib1:{a,b}
, lib2:c

build-depends: lib3:d>=1
build-depends: lib4:{a,b}>=1
145 changes: 145 additions & 0 deletions Cabal/tests/ParserTests/regressions/issue-5846.expr
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
GenericPackageDescription
{condBenchmarks = [],
condExecutables = [],
condForeignLibs = [],
condLibrary = Just
CondNode
{condTreeComponents = [],
condTreeConstraints = [Dependency
`PackageName "lib1"`
AnyVersion
(Set.fromList
[LSubLibName `UnqualComponentName "a"`,
LSubLibName `UnqualComponentName "b"`]),
Dependency
`PackageName "lib2"`
AnyVersion
(Set.fromList
[LSubLibName `UnqualComponentName "c"`]),
Dependency
`PackageName "lib3"`
(OrLaterVersion `mkVersion [1]`)
(Set.fromList
[LSubLibName `UnqualComponentName "d"`]),
Dependency
`PackageName "lib4"`
(OrLaterVersion `mkVersion [1]`)
(Set.fromList
[LSubLibName `UnqualComponentName "a"`,
LSubLibName `UnqualComponentName "b"`])],
condTreeData = Library
{exposedModules = [],
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
buildable = True,
cSources = [],
ccOptions = [],
cmmOptions = [],
cmmSources = [],
cppOptions = [],
customFieldsBI = [],
cxxOptions = [],
cxxSources = [],
defaultExtensions = [],
defaultLanguage = Just Haskell2010,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
extraLibFlavours = [],
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
includeDirs = [],
includes = [],
installIncludes = [],
jsSources = [],
ldOptions = [],
mixins = [],
oldExtensions = [],
options = PerCompilerFlavor [] [],
otherExtensions = [],
otherLanguages = [],
otherModules = [],
pkgconfigDepends = [],
profOptions = PerCompilerFlavor [] [],
sharedOptions = PerCompilerFlavor [] [],
staticOptions = PerCompilerFlavor [] [],
targetBuildDepends = [Dependency
`PackageName "lib1"`
AnyVersion
(Set.fromList
[LSubLibName
`UnqualComponentName "a"`,
LSubLibName
`UnqualComponentName "b"`]),
Dependency
`PackageName "lib2"`
AnyVersion
(Set.fromList
[LSubLibName
`UnqualComponentName "c"`]),
Dependency
`PackageName "lib3"`
(OrLaterVersion
`mkVersion [1]`)
(Set.fromList
[LSubLibName
`UnqualComponentName "d"`]),
Dependency
`PackageName "lib4"`
(OrLaterVersion
`mkVersion [1]`)
(Set.fromList
[LSubLibName
`UnqualComponentName "a"`,
LSubLibName
`UnqualComponentName "b"`])],
virtualModules = []},
libExposed = True,
libName = LMainLibName,
libVisibility = LibraryVisibilityPublic,
reexportedModules = [],
signatures = []}},
condSubLibraries = [],
condTestSuites = [],
genPackageFlags = [],
packageDescription = PackageDescription
{author = "",
benchmarks = [],
bugReports = "",
buildTypeRaw = Nothing,
category = "",
copyright = "",
customFieldsPD = [],
dataDir = "",
dataFiles = [],
description = "",
executables = [],
extraDocFiles = [],
extraSrcFiles = [],
extraTmpFiles = [],
foreignLibs = [],
homepage = "",
library = Nothing,
licenseFiles = [],
licenseRaw = Left NONE,
maintainer = "",
package = PackageIdentifier
{pkgName = `PackageName "issue"`,
pkgVersion = `mkVersion [5846]`},
pkgUrl = "",
setupBuildInfo = Nothing,
sourceRepos = [],
specVersionRaw = Left `mkVersion [3,0]`,
stability = "",
subLibraries = [],
synopsis = "",
testSuites = [],
testedWith = []}}
11 changes: 11 additions & 0 deletions Cabal/tests/ParserTests/regressions/issue-5846.format
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cabal-version: 3.0
name: issue
version: 5846

library
default-language: Haskell2010
build-depends:
lib1 : {a, b} -any,
lib2 : {c} -any,
lib3 : {d} >=1,
lib4 : {a, b} >=1

0 comments on commit e6b479a

Please sign in to comment.