Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 3.0 batch 3 #6403

Merged
merged 3 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ extra-source-files:
-- BEGIN gen-extra-source-files
tests/ParserTests/errors/MiniAgda.cabal
tests/ParserTests/errors/MiniAgda.errors
tests/ParserTests/errors/big-version.cabal
tests/ParserTests/errors/big-version.errors
tests/ParserTests/errors/common1.cabal
tests/ParserTests/errors/common1.errors
tests/ParserTests/errors/common2.cabal
Expand Down Expand Up @@ -110,6 +112,9 @@ extra-source-files:
tests/ParserTests/regressions/Octree-0.5.format
tests/ParserTests/regressions/bad-glob-syntax.cabal
tests/ParserTests/regressions/bad-glob-syntax.check
tests/ParserTests/regressions/big-version.cabal
tests/ParserTests/regressions/big-version.expr
tests/ParserTests/regressions/big-version.format
tests/ParserTests/regressions/cc-options-with-optimization.cabal
tests/ParserTests/regressions/cc-options-with-optimization.check
tests/ParserTests/regressions/common-conditional.cabal
Expand Down Expand Up @@ -159,6 +164,12 @@ 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-6083-pkg-pkg.cabal
tests/ParserTests/regressions/issue-6083-pkg-pkg.expr
tests/ParserTests/regressions/issue-6083-pkg-pkg.format
tests/ParserTests/regressions/issue-774.cabal
tests/ParserTests/regressions/issue-774.check
tests/ParserTests/regressions/issue-774.expr
Expand Down
18 changes: 18 additions & 0 deletions Cabal/Distribution/PackageDescription/Quirks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@ patches = Map.fromList
(Fingerprint 12694656661460787751 1902242956706735615)
(Fingerprint 15433152131513403849 2284712791516353264)
(bsReplace "1.2.03.0" "1.2.3.0")
-- 9 digits limit
, mk "Name: SGplus\nVersion: 1.1\nSynopsis: (updated) Small geometry library for dealing with vectors and collision detection\nLicense: BSD3\nLicense-file: LICENSE\nAuthor: Neil Brown\nMaintainer: "
(Fingerprint 17735649550442248029 11493772714725351354)
(Fingerprint 9565458801063261772 15955773698774721052)
(bsReplace "1000000000" "100000000")
, mk "-- Initial control-dotdotdot.cabal generated by cabal init. For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\nname: control-dotdotdot\nversion: 0.1.0.1\nsynopsis: Haskell operator\n "
(Fingerprint 1514257173776509942 7756050823377346485)
(Fingerprint 14082092642045505999 18415918653404121035)
(bsReplace "9223372036854775807" "5")
, mk "name: data-foldapp\r\nversion: 0.1.1.0\r\nsynopsis: Fold function applications. Framework for variadic functions.\r\ndescription: Fold function applications. Framework for variadic functions.\r\nhomepage: ht"
(Fingerprint 4511234156311243251 11701153011544112556)
(Fingerprint 11820542702491924189 4902231447612406724)
(bsReplace "9223372036854775807" "999" . bsReplace "9223372036854775807" "999")
, mk "-- Initial data-list-zigzag.cabal generated by cabal init. For further \r\n-- documentation, see http://haskell.org/cabal/users-guide/\r\n\r\nname: data-list-zigzag\r\nversion: 0.1.1.1\r\nsynopsis: A list but with a balanced en"
(Fingerprint 12475837388692175691 18053834261188158945)
(Fingerprint 16279938253437334942 15753349540193002309)
(bsReplace "9223372036854775807" "999")

]
where
mk a b c d = ((a, b), (c, d))
Expand Down
3 changes: 3 additions & 0 deletions Cabal/Distribution/Types/Dependency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ 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
Expand Down
8 changes: 7 additions & 1 deletion Cabal/Distribution/Types/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ versionDigitParser = (some d >>= toNumber) P.<?> "version digit (integral withou
toNumber :: CabalParsing m => [Int] -> m Int
toNumber [0] = return 0
toNumber (0:_) = P.unexpected "Version digit with leading zero"
toNumber xs = return $ foldl' (\a b -> a * 10 + b) 0 xs
toNumber xs
-- 10^9 = 1000000000
-- 2^30 = 1073741824
--
-- GHC Int is at least 32 bits, so 2^31-1 is the 'maxBound'.
| length xs > 9 = P.unexpected "At most 9 numbers are allowed per version number part"
| otherwise = return $ foldl' (\a b -> a * 10 + b) 0 xs

d :: P.CharParsing m => m Int
d = f <$> P.satisfyRange '0' '9'
Expand Down
4 changes: 4 additions & 0 deletions Cabal/tests/ParserTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ errorTests = testGroup "errors"
, errorTest "libpq1.cabal"
, errorTest "libpq2.cabal"
, errorTest "MiniAgda.cabal"
, errorTest "big-version.cabal"
]

errorTest :: FilePath -> TestTree
Expand Down Expand Up @@ -165,6 +166,7 @@ regressionTests = testGroup "regressions"
, regressionTest "wl-pprint-indef.cabal"
, regressionTest "th-lift-instances.cabal"
, regressionTest "issue-5055.cabal"
, regressionTest "issue-6083-pkg-pkg.cabal"
, regressionTest "noVersion.cabal"
, regressionTest "spdx-1.cabal"
, regressionTest "spdx-2.cabal"
Expand All @@ -177,9 +179,11 @@ 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"
, regressionTest "big-version.cabal"
]

regressionTest :: FilePath -> TestTree
Expand Down
7 changes: 7 additions & 0 deletions Cabal/tests/ParserTests/errors/big-version.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cabal-version: 3.0
name: big-vesion
-- 10 digits
version: 1234567890

library
default-language: Haskell2010
4 changes: 4 additions & 0 deletions Cabal/tests/ParserTests/errors/big-version.errors
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VERSION: Just (mkVersion [3,0])
big-version.cabal:4:32:
unexpected At most 9 numbers are allowed per version number part

7 changes: 7 additions & 0 deletions Cabal/tests/ParserTests/regressions/big-version.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cabal-version: 3.0
name: big-vesion
-- 9 digits
version: 123456789

library
default-language: Haskell2010
95 changes: 95 additions & 0 deletions Cabal/tests/ParserTests/regressions/big-version.expr
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
GenericPackageDescription
{condBenchmarks = [],
condExecutables = [],
condForeignLibs = [],
condLibrary = Just
CondNode
{condTreeComponents = [],
condTreeConstraints = [],
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 = [],
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 "big-vesion"`,
pkgVersion = `mkVersion [123456789]`},
pkgUrl = "",
setupBuildInfo = Nothing,
sourceRepos = [],
specVersionRaw = Left `mkVersion [3,0]`,
stability = "",
subLibraries = [],
synopsis = "",
testSuites = [],
testedWith = []}}
6 changes: 6 additions & 0 deletions Cabal/tests/ParserTests/regressions/big-version.format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cabal-version: 3.0
name: big-vesion
version: 123456789

library
default-language: Haskell2010
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
Loading