Unverified Commit 0b6e49e0 authored by Oleg Grenrus's avatar Oleg Grenrus Committed by GitHub

Merge pull request #6786 from phadej/remove-any-none

Resolve #6589: Remove -any and -none syntax
parents 3c0ff33e 8cc651c0
......@@ -21,7 +21,7 @@ import Distribution.Simple.Flag (Flag (..))
import Distribution.SPDX
import Distribution.System
import Distribution.Types.Dependency
import Distribution.Types.Flag (FlagAssignment, FlagName, mkFlagAssignment, mkFlagName)
import Distribution.Types.Flag (FlagAssignment, FlagName, mkFlagAssignment, mkFlagName, unFlagAssignment)
import Distribution.Types.LibraryName
import Distribution.Types.PackageId
import Distribution.Types.PackageName
......@@ -249,7 +249,12 @@ instance Arbitrary1 Flag where
-------------------------------------------------------------------------------
instance Arbitrary FlagName where
arbitrary = mkFlagName <$> flagident
arbitrary = mkFlagName <$> frequency
[ (20, flagident)
-- special nasty cases
, (1, pure "none")
, (1, pure "any")
]
where
flagident = lowercase <$> shortListOf1 5 (elements flagChars)
`suchThat` (("-" /=) . take 1)
......@@ -257,6 +262,7 @@ instance Arbitrary FlagName where
instance Arbitrary FlagAssignment where
arbitrary = mkFlagAssignment <$> arbitrary
shrink x = mkFlagAssignment <$> shrink (unFlagAssignment x)
-------------------------------------------------------------------------------
-- Verbosity
......
......@@ -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/anynone.cabal
tests/ParserTests/errors/anynone.errors
tests/ParserTests/errors/big-version.cabal
tests/ParserTests/errors/big-version.errors
tests/ParserTests/errors/common1.cabal
......@@ -110,6 +112,9 @@ extra-source-files:
tests/ParserTests/regressions/Octree-0.5.cabal
tests/ParserTests/regressions/Octree-0.5.expr
tests/ParserTests/regressions/Octree-0.5.format
tests/ParserTests/regressions/anynone.cabal
tests/ParserTests/regressions/anynone.expr
tests/ParserTests/regressions/anynone.format
tests/ParserTests/regressions/assoc-cpp-options.cabal
tests/ParserTests/regressions/assoc-cpp-options.check
tests/ParserTests/regressions/bad-glob-syntax.cabal
......@@ -200,6 +205,9 @@ extra-source-files:
tests/ParserTests/regressions/mixin-3.cabal
tests/ParserTests/regressions/mixin-3.expr
tests/ParserTests/regressions/mixin-3.format
tests/ParserTests/regressions/monad-param.cabal
tests/ParserTests/regressions/monad-param.expr
tests/ParserTests/regressions/monad-param.format
tests/ParserTests/regressions/multiple-libs-2.cabal
tests/ParserTests/regressions/multiple-libs-2.check
tests/ParserTests/regressions/multiple-libs-2.expr
......
......@@ -185,7 +185,8 @@ parseGenericPackageDescription' scannedVer lexWarnings utf8WarnPos fs = do
-- version will be parsed twice, therefore we parse without warnings.
v <- withoutWarnings $
Newtype.unpack' SpecVersion <$>
runFieldParser pos parsec cabalSpecLatest fls
-- Use version with || and && but before addition of ^>= and removal of -any
runFieldParser pos parsec CabalSpecV1_24 fls
-- if it were at the beginning, scanner would found it
when (v >= CabalSpecV2_2) $ parseFailure pos $
......
......@@ -172,12 +172,8 @@ instance Described Dependency where
, reChar '}'
]
]
-- TODO: RESpaces1 should be just RESpaces, but we are able
-- to generate non-parseable strings without mandatory space
--
-- https://github.com/haskell/cabal/issues/6589
--
, REOpt $ RESpaces1 <> vr
, REOpt $ RESpaces <> vr
]
where
vr = RENamed "version-range" (describe (Proxy :: Proxy VersionRange))
......
......@@ -66,9 +66,7 @@ instance Parsec PackageVersionConstraint where
instance Described PackageVersionConstraint where
describe _ = describe (Proxy :: Proxy PackageName) <> REUnion
[ fromString "-" <> describe (Proxy :: Proxy Version)
-- TODO: change to RESpaces when -any and -none are removed
-- Related https://github.com/haskell/cabal/issues/6760
, RESpaces1 <> describe (Proxy :: Proxy VersionRange)
, RESpaces <> describe (Proxy :: Proxy VersionRange)
]
thisPackageVersionConstraint :: PackageIdentifier -> PackageVersionConstraint
......
......@@ -286,6 +286,12 @@ prettyVersionRange16 vr = prettyVersionRange vr
--
-- Small history:
--
-- @-any@ and @-none@ removed in 3.4
-- Use @>=0@ and @<0@ instead.
--
-- >>> map (`simpleParsec'` "-none") [CabalSpecV3_0, CabalSpecV3_4] :: [Maybe VersionRange]
-- [Just (EarlierVersion (mkVersion [0])),Nothing]
--
-- Set operations are introduced in 3.0
--
-- >>> map (`simpleParsec'` "^>= { 1.2 , 1.3 }") [CabalSpecV2_4, CabalSpecV3_0] :: [Maybe VersionRange]
......@@ -432,7 +438,12 @@ versionRangeParser digitParser csv = expr
isOpChar '=' = True
isOpChar '>' = True
isOpChar '^' = True
isOpChar '-' = True
isOpChar '-' = csv < CabalSpecV3_4
-- https://github.com/haskell/cabal/issues/6589
-- Unfortunately we have must not consume the dash,
-- as otherwise following parts may not be parsed.
--
-- i.e. we cannot fail here with good error.
isOpChar _ = False
-- -none version range is available since 1.22
......
......@@ -22,9 +22,13 @@ relative to the respective preceding *published* version.
``cabal-version: 3.4``
----------------------
* License fields use identifiers from SPDX License List version
``3.8 2020-02-09``
* Remove ``-any`` and ``-none`` syntax for version ranges
Use ``>=0`` and ``<0`` respectively.
``cabal-version: 3.0``
----------------------
......
......@@ -17,8 +17,8 @@ import Distribution.Fields (runParseResult)
import Distribution.PackageDescription (GenericPackageDescription)
import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
import Distribution.PackageDescription.PrettyPrint (showGenericPackageDescription)
import Distribution.Parsec
(PWarnType (..), PWarning (..), showPError, showPWarning)
import Distribution.Parsec (PWarnType (..), PWarning (..), showPError, showPWarning)
import Distribution.Pretty (prettyShow)
import Distribution.Utils.Generic (fromUTF8BS, toUTF8BS)
import System.Directory (setCurrentDirectory)
import System.Environment (getArgs, withArgs)
......@@ -129,6 +129,7 @@ errorTests = testGroup "errors"
, errorTest "libpq2.cabal"
, errorTest "MiniAgda.cabal"
, errorTest "big-version.cabal"
, errorTest "anynone.cabal"
]
errorTest :: FilePath -> TestTree
......@@ -189,6 +190,8 @@ regressionTests = testGroup "regressions"
, regressionTest "indentation2.cabal"
, regressionTest "indentation3.cabal"
, regressionTest "big-version.cabal"
, regressionTest "anynone.cabal"
, regressionTest "monad-param.cabal"
]
regressionTest :: FilePath -> TestTree
......@@ -210,8 +213,11 @@ formatGoldenTest fp = cabalGoldenTest "format" correct $ do
Right gpd ->
unlines (map (showPWarning fp) warns)
++ showGenericPackageDescription gpd
Left (_, errs) ->
unlines $ "ERROR" : map (showPError fp) (NE.toList errs)
Left (csv, errs) ->
unlines $
"ERROR" :
maybe "unknown-version" prettyShow csv :
map (showPError fp) (NE.toList errs)
where
input = "tests" </> "ParserTests" </> "regressions" </> fp
correct = replaceExtension input "format"
......
cabal-version: 3.4
name: anynone
version: 0
synopsis: The -any none demo
build-type: Simple
library
default-language: Haskell2010
exposed-modules: AnyNone
build-depends: base -any
VERSION: Just (mkVersion [3,4])
anynone.cabal:10:26:
unexpected '-'
expecting space, white space, opening paren, operator, comma or end of input
cabal-version: 3.0
name: anynone
version: 0
synopsis: The -any none demo
build-type: Simple
library
default-language: Haskell2010
exposed-modules: AnyNone
build-depends: base -any
GenericPackageDescription
{condBenchmarks = [],
condExecutables = [],
condForeignLibs = [],
condLibrary = Just
CondNode
{condTreeComponents = [],
condTreeConstraints = [Dependency
`PackageName "base"`
(OrLaterVersion `mkVersion [0]`)
(Set.fromList [LMainLibName])],
condTreeData = Library
{exposedModules = [`ModuleName "AnyNone"`],
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 "base"`
(OrLaterVersion
`mkVersion [0]`)
(Set.fromList
[LMainLibName])],
virtualModules = []},
libExposed = True,
libName = LMainLibName,
libVisibility = LibraryVisibilityPublic,
reexportedModules = [],
signatures = []}},
condSubLibraries = [],
condTestSuites = [],
genPackageFlags = [],
gpdScannedVersion = Nothing,
packageDescription = PackageDescription
{author = "",
benchmarks = [],
bugReports = "",
buildTypeRaw = Just Simple,
category = "",
copyright = "",
customFieldsPD = [],
dataDir = "",
dataFiles = [],
description = "",
executables = [],
extraDocFiles = [],
extraSrcFiles = [],
extraTmpFiles = [],
foreignLibs = [],
homepage = "",
library = Nothing,
licenseFiles = [],
licenseRaw = Left NONE,
maintainer = "",
package = PackageIdentifier
{pkgName = `PackageName "anynone"`,
pkgVersion = `mkVersion [0]`},
pkgUrl = "",
setupBuildInfo = Nothing,
sourceRepos = [],
specVersion = CabalSpecV3_0,
stability = "",
subLibraries = [],
synopsis = "The -any none demo",
testSuites = [],
testedWith = []}}
cabal-version: 3.0
name: anynone
version: 0
synopsis: The -any none demo
build-type: Simple
library
exposed-modules: AnyNone
default-language: Haskell2010
build-depends: base
name: monad-param
category: Control
version: 0.0.1
synopsis: Parameterized monads
description: Implements parameterized monads by overloading the monad sugar with more liberal types.
stability: alpha
author: Edward Kmett <ekmett@gmail.com>
maintainer: Edward Kmett <ekmett@gmail.com>
copyright: Copyright (C) 2006-2007, Edward Kmett
homepage: http://comonad.com/haskell/monad-param/dist/doc/html/Control-Monad-Parameterized.html
package-url: http://comonad.com/haskell/monad-param
build-depends: base -any, mtl -any, stm -any
cabal-version: -any
license: BSD3
license-file: LICENSE
buildable: True
extensions: MultiParamTypeClasses
FunctionalDependencies
OverlappingInstances
UndecidableInstances
EmptyDataDecls
NoImplicitPrelude
exposed-modules: Control.Monad.Parameterized
ghc-options: -funbox-strict-fields -threaded -fasm
hs-source-dirs: src
GenericPackageDescription
{condBenchmarks = [],
condExecutables = [],
condForeignLibs = [],
condLibrary = Just
CondNode
{condTreeComponents = [],
condTreeConstraints = [Dependency
`PackageName "base"`
(OrLaterVersion `mkVersion [0]`)
(Set.fromList [LMainLibName]),
Dependency
`PackageName "mtl"`
(OrLaterVersion `mkVersion [0]`)
(Set.fromList [LMainLibName]),
Dependency
`PackageName "stm"`
(OrLaterVersion `mkVersion [0]`)
(Set.fromList [LMainLibName])],
condTreeData = Library
{exposedModules = [`ModuleName "Control.Monad.Parameterized"`],
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
buildable = True,
cSources = [],
ccOptions = [],
cmmOptions = [],
cmmSources = [],
cppOptions = [],
customFieldsBI = [],
cxxOptions = [],
cxxSources = [],
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
extraLibFlavours = [],
extraLibs = [],
frameworks = [],
hsSourceDirs = ["src"],
includeDirs = [],
includes = [],
installIncludes = [],
jsSources = [],
ldOptions = [],
mixins = [],
oldExtensions = [EnableExtension
MultiParamTypeClasses,
EnableExtension
FunctionalDependencies,
EnableExtension
OverlappingInstances,
EnableExtension
UndecidableInstances,
EnableExtension
EmptyDataDecls,
DisableExtension
ImplicitPrelude],
options = PerCompilerFlavor
["-funbox-strict-fields",
"-threaded",
"-fasm"]
[],
otherExtensions = [],
otherLanguages = [],
otherModules = [],
pkgconfigDepends = [],
profOptions = PerCompilerFlavor [] [],
sharedOptions = PerCompilerFlavor [] [],
staticOptions = PerCompilerFlavor [] [],
targetBuildDepends = [Dependency
`PackageName "base"`
(OrLaterVersion
`mkVersion [0]`)
(Set.fromList
[LMainLibName]),
Dependency
`PackageName "mtl"`
(OrLaterVersion
`mkVersion [0]`)
(Set.fromList
[LMainLibName]),
Dependency
`PackageName "stm"`
(OrLaterVersion
`mkVersion [0]`)
(Set.fromList
[LMainLibName])],
virtualModules = []},
libExposed = True,
libName = LMainLibName,
libVisibility = LibraryVisibilityPublic,
reexportedModules = [],
signatures = []}},
condSubLibraries = [],
condTestSuites = [],
genPackageFlags = [],
gpdScannedVersion = Nothing,
packageDescription = PackageDescription
{author = "Edward Kmett <ekmett@gmail.com>",
benchmarks = [],
bugReports = "",
buildTypeRaw = Nothing,
category = "Control",
copyright = "Copyright (C) 2006-2007, Edward Kmett",
customFieldsPD = [],
dataDir = "",
dataFiles = [],
description = "Implements parameterized monads by overloading the monad sugar with more liberal types.",
executables = [],
extraDocFiles = [],
extraSrcFiles = [],
extraTmpFiles = [],
foreignLibs = [],
homepage = "http://comonad.com/haskell/monad-param/dist/doc/html/Control-Monad-Parameterized.html",
library = Nothing,
licenseFiles = ["LICENSE"],
licenseRaw = Right BSD3,
maintainer = "Edward Kmett <ekmett@gmail.com>",
package = PackageIdentifier
{pkgName = `PackageName "monad-param"`,
pkgVersion = `mkVersion [0,0,1]`},
pkgUrl = "http://comonad.com/haskell/monad-param",
setupBuildInfo = Nothing,
sourceRepos = [],
specVersion = CabalSpecV1_0,
stability = "alpha",
subLibraries = [],
synopsis = "Parameterized monads",
testSuites = [],
testedWith = []}}
monad-param.cabal:19:3: Tabs used as indentation at 19:3, 20:3
name: monad-param
version: 0.0.1
license: BSD3
license-file: LICENSE
copyright: Copyright (C) 2006-2007, Edward Kmett
maintainer: Edward Kmett <ekmett@gmail.com>
author: Edward Kmett <ekmett@gmail.com>
stability: alpha
homepage:
http://comonad.com/haskell/monad-param/dist/doc/html/Control-Monad-Parameterized.html
package-url: http://comonad.com/haskell/monad-param
synopsis: Parameterized monads
description:
Implements parameterized monads by overloading the monad sugar with more liberal types.
category: Control
library
exposed-modules: Control.Monad.Parameterized
hs-source-dirs: src
extensions:
MultiParamTypeClasses FunctionalDependencies OverlappingInstances
UndecidableInstances EmptyDataDecls NoImplicitPrelude
ghc-options: -funbox-strict-fields -threaded -fasm
build-depends:
base,
mtl,
stm
......@@ -734,8 +734,7 @@ instance Described UserConstraint where
describeConstraintProperty :: GrammarRegex void
describeConstraintProperty = REUnion
-- TODO: change first to RESpaces when -any and -none are removed
[ RESpaces1 <> RENamed "version-range" (describe (Proxy :: Proxy VersionRange))
[ RESpaces <> RENamed "version-range" (describe (Proxy :: Proxy VersionRange))
, RESpaces1 <> describeConstraintProperty'
]
......
synopsis: Remove `-any` and `-none` syntax for version ranges in cabal-version: 3.4
issues: #6589
description:
Use `>=0` (or empty in dependencies) and `<0` respectively.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment