haskell / haskell/cabal

Allow-newer conditional on GHC-version is not respected

Open
#9,158 4 comments 0 reactions 0 assignees View on GitHub
re: conditional type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**

The `allow-newer` constraints don't get respected when enclosed in a conditional block.

**To Reproduce**
Checkout this commit: https://github.com/input-output-hk/ouroboros-consensus/tree/ed184183d048af6126f9e00e32862d669e705899. And maybe you need to install some dependencies, in particular `pkg-config`, `libsodium` and `liblmdb-dev` in Ubuntu.

```
cabal build all --with-compiler=ghc-9.6.2 --dry-run
```

succesfully creates a build plan. However, applying this diff:

```diff
allow-newer:
, lens
, cardano-ledger-core
, cardano-ledger-alonzo
, cardano-ledger-babbage
+if impl(ghc >= 9.6)
+ allow-newer:
+ , *:base
+ , *:ghc-prim
- , *:base
- , *:ghc-prim
```

results in cabal failing to create a build plan, by saying:

```
[__3] rejecting: base-4.18.0.0/installed-4.18.0.0 (conflict: small-steps-test => base>=4.12 && <4.17)
```

So the constraint `allow-newer: *:base` is not being respected.

**Expected behavior**

I expected cabal to produce a build plan.

**System information**
- Ubuntu 23.04
- cabal 3.10.1.0
- ghc 9.6.2

Contributor guide

Open the contributing guide

Research direction

Check out commit ed184183d048af6126f9e00e32862d669e705899 and reproduce the issue with cabal build all --with-compiler=ghc-9.6.2 --dry-run, installing pkg-config, libsodium, and liblmdb-dev if needed. Compare the working top-level allow-newer constraints with the conditional impl(ghc >= 9.6) form; done means the conditional *:base and *:ghc-prim constraints are respected and a build plan is produced.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.