Skip to content

Additional flag settings are ignored if the original ones are in a conditional block #9293

Open
@michaelpj

Description

@michaelpj

Describe the bug
This is a weird one. What I'm observing is that this:

package foo
   flags: +bar

package foo
   flags: -bar

builds foo with bar disabled (correct), but that this:

-- Assume we're using GHC > 9 so this conditional is satisfied
if impl(ghc>9)
   package foo
       flags: +bar

pacakge foo
   flags: -bar

builds foo with bar enabled (incorrect).

To Reproduce

  • Checkout https://github.com/haskell/lsp/tree/mpj/cabal-bug
  • cabal build lsp (with GHC > 9 so the conditional is satisfied)
    • Observe that cabal declares that it is going to build exe:lsp-demo-simple-server
  • Remove the conditional around the flag setting in cabal.project
  • cabal build lsp
    • Observe that cabal does not declare that it is going to build exe:lsp-demo-simple-server

Expected behavior

The second flag setting should override the first regardless of whether the first one is conditional.

System information

  • NixOS
  • `cabal-3.10.1.01
  • ghc-9.2.7

Additional context

I don't think this is #8699, because:

  1. I can reproduce it even if I wipe out dist-newstyle before building; and
  2. The problem is not the conditional section being ignored, but rather the later unconditional section being ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    attention: pr-welcomecan-workaroundThere is a (maybe partial) workaround for the issue or missing featurere: conditionalAbout conditional declarations in cabal files(`if`)re: flagConcerning user-defined flags in cabal filesre: project-fileConcerning cabal.project filestype: bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions