Skip to content

Commit

Permalink
Warn about missing default-language
Browse files Browse the repository at this point in the history
To accomodate GHC language editions (GHC2021, GHC2024, etc.).
  • Loading branch information
ffaf1 committed Jan 17, 2024
1 parent c58e17d commit c38a662
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[no-default-language] 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.
[no-default-language] 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.
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ maintainer: Cabal Contributors

library
exposed-modules: Foo
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ library
GHC.Hs.Type
hs-source-dirs:
compat-8.10
default-language: Haskell2010
2 changes: 2 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/issue-7776-b.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ library
-- the base lower bound makes the package not buildable with ghc < 6.8
-- but cabal is not smart enough to know it :-P
build-depends: base >= 4.5 && < 4.15
default-language: Haskell2010

benchmark benchmarks
main-is: Benchmarks.hs
Expand All @@ -25,3 +26,4 @@ benchmark benchmarks
Ghc-options: -fwarn-tabs
else
other-modules: Data.Hashable.RandomSource
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ library
compat
other-modules:
GHC.Hs.Type
default-language: Haskell2010
Expand Down
1 change: 0 additions & 1 deletion Cabal/src/Distribution/PackageDescription/Check/Target.hs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ checkBuildInfoFeatures bi sv = do
-- CheckSpecVer sv.
checkP
( sv >= CabalSpecV1_10
&& sv < CabalSpecV3_4
&& isNothing (defaultLanguage bi)
)
(PackageBuildWarning CVDefaultLanguageComponent)
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/PackageDescription/Check/Warning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ ppExplanation CVDefaultLanguage =
"To use the 'default-language' field the package needs to specify "
++ "at least 'cabal-version: >= 1.10'."
ppExplanation CVDefaultLanguageComponent =
"Packages using 'cabal-version: >= 1.10' and before 'cabal-version: 3.4' "
"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 "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cabal check
The following errors are likely to affect your build negatively:
Error: [no-default-language] 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.
Error: [no-default-language] 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.
Error: Hackage would reject this package.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 3.0
cabal-version: 3.4
name: pkg
synopsis: synopsis
description: description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Executable TestPackageInfoModule
PackageInfo_PackageInfoModule
Paths_PackageInfoModule
build-depends: base
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Executable TestPackageInfoModule
PackageInfo_PackageInfoModule
Paths_PackageInfoModule
build-depends: base
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Executable TestPathsModule
PackageInfo_PathsModule
Paths_PathsModule
build-depends: base
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Executable TestPathsModule
PackageInfo_PathsModule
Paths_PathsModule
build-depends: base
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Executable TestPathsModule
PackageInfo_PathsModule
Paths_PathsModule
build-depends: base
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ executable my-executable
other-modules: Foo
build-depends: base
hsc2hs-options: -DTEST_OPTION=42
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ executable my-executable
build-depends: base
other-modules: Foo
hsc2hs-options: "--cc=g++"
default-language: Haskell2010
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/ProfLate/profLate.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Build-Type: Simple
Executable main
Main-is: Exe.hs
Build-Depends: base
default-language: Haskell2010
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ In order, the following will be built:
- pkg-a-0.1 (lib) (first run)
- pkg-a-0.1 (test:testing) (first run)
Configuring library for pkg-a-0.1...
Warning: [no-default-language] 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.
Preprocessing library for pkg-a-0.1...
Building library for pkg-a-0.1...
Configuring test suite 'testing' for pkg-a-0.1...
Warning: [no-default-language] 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.
Preprocessing test suite 'testing' for pkg-a-0.1...
Building test suite 'testing' for pkg-a-0.1...
Running 1 test suites...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ test-suite testing
build-depends: base, pkg-a
main-is: Main.hs
hs-source-dirs: test
default-language: Haskell2010

3 changes: 0 additions & 3 deletions cabal-testsuite/PackageTests/Regression/T6440/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ In order, the following will be built:
- cabal6440-0.1 (lib) (first run)
- cabal6440-0.1 (test:tests) (first run)
Configuring library 'intern6440' for cabal6440-0.1...
Warning: [no-default-language] 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.
Preprocessing library 'intern6440' for cabal6440-0.1...
Building library 'intern6440' for cabal6440-0.1...
Configuring library for cabal6440-0.1...
Warning: [no-default-language] 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.
Preprocessing library for cabal6440-0.1...
Building library for cabal6440-0.1...
Configuring test suite 'tests' for cabal6440-0.1...
Warning: [no-default-language] 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.
Preprocessing test suite 'tests' for cabal6440-0.1...
Building test suite 'tests' for cabal6440-0.1...
Running 1 test suites...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ library intern6440
exposed-modules: Inn
build-depends: base
hs-source-dirs: srcint
default-language: Haskell2010


test-suite tests
Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Regression/T9122/p/p.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Version: 2
Build-Type: Simple

library
default-language: Haskell2010
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T9122/q/q.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Build-Type: Simple

library
build-depends: q:p
default-language: Haskell2010

library p
build-depends: p:p == 2
default-language: Haskell2010
9 changes: 9 additions & 0 deletions changelog.d/pr-9621
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
synopsis: Warn about missing `default-language`
packages: Cabal cabal-install
prs: #9621
issues: #9620
description: {

- `cabal check` will warn about missing `default-language` and not assume `Haskell 2010`.

}

0 comments on commit c38a662

Please sign in to comment.