Skip to content

Commit

Permalink
Resolve #6288
Browse files Browse the repository at this point in the history
- 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 #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
  • Loading branch information
phadej committed Jun 22, 2020
1 parent d7fd25a commit 57bdc6e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cabal/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
5 changes: 5 additions & 0 deletions Cabal/Distribution/PackageDescription/FieldGrammar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
3 changes: 3 additions & 0 deletions Cabal/doc/file-format-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/ParserTests/regressions/issue-6288-a.check
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion Cabal/tests/ParserTests/regressions/issue-6288-d.check
Original file line number Diff line number Diff line change
@@ -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.
1 change: 0 additions & 1 deletion Cabal/tests/ParserTests/regressions/issue-6288-f.check
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 57bdc6e

Please sign in to comment.