diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal index 58c3fdadda6..6957a691264 100644 --- a/Cabal/Cabal.cabal +++ b/Cabal/Cabal.cabal @@ -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 @@ -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 @@ -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 diff --git a/Cabal/Distribution/PackageDescription/Quirks.hs b/Cabal/Distribution/PackageDescription/Quirks.hs index 37d75e8aeae..0b6f8345fbc 100644 --- a/Cabal/Distribution/PackageDescription/Quirks.hs +++ b/Cabal/Distribution/PackageDescription/Quirks.hs @@ -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)) diff --git a/Cabal/Distribution/Types/Dependency.hs b/Cabal/Distribution/Types/Dependency.hs index b8c78c67518..3ec5d9846b9 100644 --- a/Cabal/Distribution/Types/Dependency.hs +++ b/Cabal/Distribution/Types/Dependency.hs @@ -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 diff --git a/Cabal/Distribution/Types/Version.hs b/Cabal/Distribution/Types/Version.hs index 0a0cd3effd4..162de5f8509 100644 --- a/Cabal/Distribution/Types/Version.hs +++ b/Cabal/Distribution/Types/Version.hs @@ -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' diff --git a/Cabal/tests/ParserTests.hs b/Cabal/tests/ParserTests.hs index 9aba7466e31..2e98a8b6fac 100644 --- a/Cabal/tests/ParserTests.hs +++ b/Cabal/tests/ParserTests.hs @@ -123,6 +123,7 @@ errorTests = testGroup "errors" , errorTest "libpq1.cabal" , errorTest "libpq2.cabal" , errorTest "MiniAgda.cabal" + , errorTest "big-version.cabal" ] errorTest :: FilePath -> TestTree @@ -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" @@ -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 diff --git a/Cabal/tests/ParserTests/errors/big-version.cabal b/Cabal/tests/ParserTests/errors/big-version.cabal new file mode 100644 index 00000000000..533dae563aa --- /dev/null +++ b/Cabal/tests/ParserTests/errors/big-version.cabal @@ -0,0 +1,7 @@ +cabal-version: 3.0 +name: big-vesion +-- 10 digits +version: 1234567890 + +library + default-language: Haskell2010 diff --git a/Cabal/tests/ParserTests/errors/big-version.errors b/Cabal/tests/ParserTests/errors/big-version.errors new file mode 100644 index 00000000000..b51efaaf466 --- /dev/null +++ b/Cabal/tests/ParserTests/errors/big-version.errors @@ -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 + diff --git a/Cabal/tests/ParserTests/regressions/big-version.cabal b/Cabal/tests/ParserTests/regressions/big-version.cabal new file mode 100644 index 00000000000..1812bdde664 --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/big-version.cabal @@ -0,0 +1,7 @@ +cabal-version: 3.0 +name: big-vesion +-- 9 digits +version: 123456789 + +library + default-language: Haskell2010 diff --git a/Cabal/tests/ParserTests/regressions/big-version.expr b/Cabal/tests/ParserTests/regressions/big-version.expr new file mode 100644 index 00000000000..0bfaeb4c370 --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/big-version.expr @@ -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 = []}} diff --git a/Cabal/tests/ParserTests/regressions/big-version.format b/Cabal/tests/ParserTests/regressions/big-version.format new file mode 100644 index 00000000000..c1e68ec0834 --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/big-version.format @@ -0,0 +1,6 @@ +cabal-version: 3.0 +name: big-vesion +version: 123456789 + +library + default-language: Haskell2010 diff --git a/Cabal/tests/ParserTests/regressions/issue-5846.cabal b/Cabal/tests/ParserTests/regressions/issue-5846.cabal new file mode 100644 index 00000000000..dc76d4059d2 --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/issue-5846.cabal @@ -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 diff --git a/Cabal/tests/ParserTests/regressions/issue-5846.expr b/Cabal/tests/ParserTests/regressions/issue-5846.expr new file mode 100644 index 00000000000..6b2b7f707ea --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/issue-5846.expr @@ -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 = []}} diff --git a/Cabal/tests/ParserTests/regressions/issue-5846.format b/Cabal/tests/ParserTests/regressions/issue-5846.format new file mode 100644 index 00000000000..7ddb6afaee1 --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/issue-5846.format @@ -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 diff --git a/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.cabal b/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.cabal new file mode 100644 index 00000000000..827834afc29 --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.cabal @@ -0,0 +1,9 @@ +cabal-version: 3.0 +name: issue +version: 6083 + +library + default-language: Haskell2010 + -- This should be parsed as the main lib + build-depends: freetype + build-depends: freetype:freetype diff --git a/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr b/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr new file mode 100644 index 00000000000..9192103977f --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr @@ -0,0 +1,111 @@ +GenericPackageDescription + {condBenchmarks = [], + condExecutables = [], + condForeignLibs = [], + condLibrary = Just + CondNode + {condTreeComponents = [], + condTreeConstraints = [Dependency + `PackageName "freetype"` + AnyVersion + (Set.fromList [LMainLibName]), + Dependency + `PackageName "freetype"` + AnyVersion + (Set.fromList [LMainLibName])], + 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 "freetype"` + AnyVersion + (Set.fromList + [LMainLibName]), + Dependency + `PackageName "freetype"` + AnyVersion + (Set.fromList + [LMainLibName])], + 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 [6083]`}, + pkgUrl = "", + setupBuildInfo = Nothing, + sourceRepos = [], + specVersionRaw = Left `mkVersion [3,0]`, + stability = "", + subLibraries = [], + synopsis = "", + testSuites = [], + testedWith = []}} diff --git a/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.format b/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.format new file mode 100644 index 00000000000..da7fecdf60a --- /dev/null +++ b/Cabal/tests/ParserTests/regressions/issue-6083-pkg-pkg.format @@ -0,0 +1,9 @@ +cabal-version: 3.0 +name: issue +version: 6083 + +library + default-language: Haskell2010 + build-depends: + freetype -any, + freetype -any