From 57bdc6ed5016d4db84ba6536e36d3f9c0ac647f2 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Mon, 22 Jun 2020 09:50:03 +0300 Subject: [PATCH] Resolve #6288 - Add availableSince to language/extension fields - Also autogen-modules once we are on that. - Remove default-language check for cabal-version: 3.4 We cannot make the field `uniqueFieldAlaDef`, as that would require specifying `default-language` in each subconditional. I leave it for https://github.com/haskell/cabal/issues/6925 Note: the default language is whatever is the compiler's default. The GHC-8.10 default is its variant of Haskell2010 with NondecreasingIndentation and without DatatypeContexts --- Cabal/Distribution/PackageDescription/Check.hs | 4 ++-- Cabal/Distribution/PackageDescription/FieldGrammar.hs | 5 +++++ Cabal/doc/file-format-changelog.rst | 3 +++ Cabal/tests/ParserTests/regressions/issue-6288-a.check | 2 +- Cabal/tests/ParserTests/regressions/issue-6288-d.check | 2 +- Cabal/tests/ParserTests/regressions/issue-6288-f.check | 1 - 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cabal/Distribution/PackageDescription/Check.hs b/Cabal/Distribution/PackageDescription/Check.hs index 183d0c272d2..db8999429ab 100644 --- a/Cabal/Distribution/PackageDescription/Check.hs +++ b/Cabal/Distribution/PackageDescription/Check.hs @@ -1151,10 +1151,10 @@ checkCabalVersion pkg = "To use the 'default-language' field the package needs to specify " ++ "at least 'cabal-version: >= 1.10'." - , check (specVersion pkg >= CabalSpecV1_10 + , check (specVersion pkg >= CabalSpecV1_10 && specVersion pkg < CabalSpecV3_4 && (any isNothing (buildInfoField defaultLanguage))) $ PackageBuildWarning $ - "Packages using 'cabal-version: >= 1.10' must specify the " + "Packages using 'cabal-version: >= 1.10' and before 'cabal-version: 3.4' must specify the " ++ "'default-language' field for each component (e.g. Haskell98 or " ++ "Haskell2010). If a component uses different languages in " ++ "different modules then list the other ones in the " diff --git a/Cabal/Distribution/PackageDescription/FieldGrammar.hs b/Cabal/Distribution/PackageDescription/FieldGrammar.hs index 68fe34b51f3..2db4d541b1b 100644 --- a/Cabal/Distribution/PackageDescription/FieldGrammar.hs +++ b/Cabal/Distribution/PackageDescription/FieldGrammar.hs @@ -530,10 +530,15 @@ buildInfoFieldGrammar = BuildInfo <*> monoidalFieldAla "virtual-modules" (alaList' VCat MQuoted) L.virtualModules ^^^ availableSince CabalSpecV2_2 [] <*> monoidalFieldAla "autogen-modules" (alaList' VCat MQuoted) L.autogenModules + ^^^ availableSince CabalSpecV2_0 [] <*> optionalFieldAla "default-language" MQuoted L.defaultLanguage + ^^^ availableSince CabalSpecV1_10 Nothing <*> monoidalFieldAla "other-languages" (alaList' FSep MQuoted) L.otherLanguages + ^^^ availableSince CabalSpecV1_10 [] <*> monoidalFieldAla "default-extensions" (alaList' FSep MQuoted) L.defaultExtensions + ^^^ availableSince CabalSpecV1_10 [] <*> monoidalFieldAla "other-extensions" formatOtherExtensions L.otherExtensions + ^^^ availableSince CabalSpecV1_10 [] <*> monoidalFieldAla "extensions" (alaList' FSep MQuoted) L.oldExtensions ^^^ deprecatedSince CabalSpecV1_12 "Please use 'default-extensions' or 'other-extensions' fields." diff --git a/Cabal/doc/file-format-changelog.rst b/Cabal/doc/file-format-changelog.rst index 2701845d828..dbdf94d2a0d 100644 --- a/Cabal/doc/file-format-changelog.rst +++ b/Cabal/doc/file-format-changelog.rst @@ -34,6 +34,9 @@ relative to the respective preceding *published* version. * Remove ``-any`` and ``-none`` syntax for version ranges Use ``>=0`` and ``<0`` respectively. +* :pkg-field:`default-language` is optional. + The Default value is to use the compiler's default language. + * :pkg-field:`mixins` field allow specifying a sublibrary. ``cabal-version: 3.0`` diff --git a/Cabal/tests/ParserTests/regressions/issue-6288-a.check b/Cabal/tests/ParserTests/regressions/issue-6288-a.check index 93573a39649..96db610f93c 100644 --- a/Cabal/tests/ParserTests/regressions/issue-6288-a.check +++ b/Cabal/tests/ParserTests/regressions/issue-6288-a.check @@ -1 +1 @@ -To use the 'default-language' field the package needs to specify at least 'cabal-version: >= 1.10'. +issue-6288-a.cabal:13:3: The field "default-language" is available only since the Cabal specification version 1.10. This field will be ignored. diff --git a/Cabal/tests/ParserTests/regressions/issue-6288-d.check b/Cabal/tests/ParserTests/regressions/issue-6288-d.check index a224fa83b4b..5246b90363e 100644 --- a/Cabal/tests/ParserTests/regressions/issue-6288-d.check +++ b/Cabal/tests/ParserTests/regressions/issue-6288-d.check @@ -1 +1 @@ -Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field. +Packages using 'cabal-version: >= 1.10' and before 'cabal-version: 3.4' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field. diff --git a/Cabal/tests/ParserTests/regressions/issue-6288-f.check b/Cabal/tests/ParserTests/regressions/issue-6288-f.check index a224fa83b4b..e69de29bb2d 100644 --- a/Cabal/tests/ParserTests/regressions/issue-6288-f.check +++ b/Cabal/tests/ParserTests/regressions/issue-6288-f.check @@ -1 +0,0 @@ -Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.