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 on missing default-language #9620

Closed
adamgundry opened this issue Jan 17, 2024 · 5 comments · Fixed by #9766
Closed

Warn on missing default-language #9620

adamgundry opened this issue Jan 17, 2024 · 5 comments · Fixed by #9766

Comments

@adamgundry
Copy link
Member

adamgundry commented Jan 17, 2024

default-language has been optional for some time (see #6288). However, now that GHC has started introducing language editions like GHC2021 and GHC2024, packages that do not specify a default-language may be broken when GHC's default changes will fall back to Haskell98, potentially unexpectedly. Thus it would be better if cabal check issued a warning about such packages.

See discussion from ghc-proposals/ghc-proposals#613 (comment) onwards. As @gbaz notes:

We have a pretty clear plan of action that we can all agree on -- a pr to the cabal repo that creates a warning for missing language of at least "suspicious" severity -- which will lead to it being classified by isHackageDistError as something hackage would reject, and will lead to hackage, when it moves to using the new version of the cabal library, indeed rejecting the package.

@ffaf1
Copy link
Collaborator

ffaf1 commented Jan 17, 2024

But it already does:

f@x270:/tmp/prova$ cat prova.cabal
cabal-version:   3.0
name:            prova
version:         0.1.0.0
extra-doc-files: CHANGELOG.md
author:          Francesco Ariis
maintainer:      fa-ml@ariis.it
build-type:      Simple
license:         GPL-3.0-or-later
category:        test
synopsis:        short
description:     quite a long desc

common warnings
    ghc-options: -Wall

executable prova
    import:           warnings
    main-is:          Main.hs
    build-depends:    base ^>=4.18.1.0
    hs-source-dirs:   app

f@x270:/tmp/prova$ cabal check
Warning: this is a debug build of cabal-install with assertions enabled.
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: Hackage would reject this package.

Is that enough for you?

edit: I see, 3.4 or later.

@adamgundry
Copy link
Member Author

Exactly, the warning should appear on cabal-version 3.4 and later as well.

@ffaf1 ffaf1 self-assigned this Jan 17, 2024
@ffaf1
Copy link
Collaborator

ffaf1 commented Jan 31, 2024

@adamgundry after checking the relevant code, a cabal dev (I forgot who specifically, sorry) discovered that cabal defaults to Haskell98 when default-language is missing (see #9668).

Would this solve your issue?

@adamgundry
Copy link
Member Author

That's good news from a stability perspective. I think this feature request still makes sense, because it's very non-obvious that this default exists, so having cabal check encourage users to be explicit about default-language seems like a good idea. But it's less urgent in the light of #9668.

@ffaf1
Copy link
Collaborator

ffaf1 commented Feb 2, 2024

I plan to add a soft warning to cabal check, very good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants