Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about missing default-language #9621

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this. All the other times this behavior was changed it was restricted to a new spec version, but now we are changing an existing spec. Should we warn only when cabal-version is at least 3.11 instead?

Copy link
Collaborator Author

@ffaf1 ffaf1 Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am checking #6926 and I am just seeing a ^^^ availableSince CabalSpecV1_10 Nothing w/r/t spec (specifically: there is nothing regarding CabalSpecV3_4).

More in general, I don’t think we are messing with the spec this time (compare with PackageInfo fiasco), we are just dealing with check behaviour, but I might be wrong. (eidt: and we are more restrictive in what we accept)

cabal check raison d'être is (also) to mirror future Hackage behaviour; if Hackage decides not to accept packages withouth default-language for all cabal spec versions, cabal check should follow that.

&& isNothing (defaultLanguage bi)
)
(PackageBuildWarning CVDefaultLanguageComponent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gbaz does hackage reject uploads that have PackageBuildWarnings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does

https://github.com/haskell/hackage-server/blob/1daf74881c2ab7820bd5be8008274490bd9ccd87/src/Distribution/Server/Packages/Unpack.hs#L297-L305

(and we should remember to change this bit to isHackageDistError as soon as Cabal 3.12 is released)

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`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this comment is accurate, if you see Distribution.Simple.GHC.Internal, not specifying a default-language defaults to Haskell98.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#6926 says otherwise. maybe buildinfo gets populated anyway? we should test with -v3`

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is specifically about check though.

Would removing “ and not assume Haskell 2010” be ok for you?

Copy link
Collaborator

@fendor fendor Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Cabal changelog also claims it uses the compiler's default language: https://cabal.readthedocs.io/en/stable/file-format-changelog.html#cabal-version-3-4.


}
Loading