Skip to content
Open
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
Expand Up @@ -227,7 +227,7 @@ instantiateProjectConfigSkeletonWithCompiler os arch impl _flags skel = go $ map
go :: CondTree FlagName ([(Maybe URI, ProjectConfigPath)], ProjectConfig) -> ProjectConfig
go (CondNode (_, l) ts) =
let branches = concatMap processBranch ts
in l <> mconcat branches
in mconcat branches <> l
processBranch (CondBranch cnd t mf) = case cnd of
(Lit True) -> [go t]
(Lit False) -> maybe [] ((: []) . go) mf
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# cabal build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- test-0.1 (lib) (first run)
Configuring library for test-0.1...
Preprocessing library for test-0.1...
Building library for test-0.1...
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
packages: .

if impl(ghc >= 9.0)
package test
flags: +bar

package test
flags: -bar
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude

main = cabalTest $ do
cabal "build" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cabal-version: 3.0
name: test
version: 0.1
license: BSD-3-Clause
build-type: Simple

flag bar
default: True
manual: True

library
default-language: Haskell2010
if flag(bar)
buildable: False
28 changes: 28 additions & 0 deletions changelog.d/12279.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
synopsis: Unconditional project settings now override settings in conditional clauses
packages: [cabal-install]
prs: 12279
issues: 9293
---

Fix a bug where an unconditional setting in a project file (e.g.
`cabal.project` or an imported file such as `cabal.project.local`) was silently
ignored when an earlier setting for the same option appeared inside a
conditional clause.

Previously the conditional clauses were always merged _after_ the unconditional
fields, so a conditional won regardless of where it appeared in the file:

```cabal
if impl(ghc >= 9.0)
package foo
flags: +bar

package foo
flags: -bar
```

This would build `foo` with `bar` enabled, because `+bar` was applied last.
The skeleton is now combined in the opposite order, applying the unconditional
fields last so they take precedence over the conditional ones. Overrides in
`cabal.project.local` are therefore no longer shadowed by conditionals.
Loading