Skip to content

ox-arrays stopped compiling due to recent GHC commits: "solveWanteds: too many iterations"

Summary

Package ox-arrays compiles fine with GHC 9.12.2 and a slightly earlier version of ox-arrays compiled fine with !10479 (closed) from a month ago or so. It does not compile with branch ghc-9.14, commit 7b814248, which is after the merge of @simonpj's final !10479 (closed).

cabal test -w /home/mikolaj/r/ghc.pre9.14/ghc/_build/stage1/bin/ghc --allow-newer --enable-optimization
...
Building library 'strided-array-ops' for ox-arrays-0.1.0.0...
[5 of 7] Compiling Data.Array.Strided.Arith.Internal ( ops/Data/Array/Strided/Arith/Internal.hs, dist-newstyle/build/x86_64-linux/ghc-9.14.0.20250815/ox-arrays-0.1.0.0/l/strided-array-ops/build/strided-array-ops/Data/Array/Strided/Arith/Internal.o, dist-newstyle/build/x86_64-linux/ghc-9.14.0.20250815/ox-arrays-0.1.0.0/l/strided-array-ops/build/strided-array-ops/Data/Array/Strided/Arith/Internal.dyn_o )
ops/Data/Array/Strided/Arith/Internal.hs:1:1: error: [GHC-95822]
    solveWanteds: too many iterations (limit = 4)
      Unsolved: WC {wc_simple =
                      [W] $dKnownNat_a7rv {0} :: KnownNat n' (CNonCanonical)
                      [W] $dKnownNat_a7rw {0} :: KnownNat 1 (CNonCanonical)
                      [W] $d~_a7rx {0} :: (1 <= n') ~ (() :: Constraint) (CNonCanonical)
                      [W] hole{co_a7rt} {0}
                            :: ghc-internal-9.1400.0:GHC.Internal.TypeError.Assert
                                 (ghc-internal-9.1400.0:GHC.Internal.Data.Type.Ord.OrdCond
                                    (CmpNat 1 n') True True False)
                                 (TypeError ...)
                               ~# () :: Constraint (CNonCanonical)
                      [W] $dKnownNat_a7re {0} :: KnownNat n' (CDictCan)
                      [W] $dKnownNat_a6Nt {0} :: KnownNat n (CDictCan)}
      Simples: {[W] $dKnownNat_a6Nt {0} :: KnownNat n (CDictCan)}
    Suggested fix:
      Set limit with -fconstraint-solver-iterations=n; n=0 for no limit

Adding

# OPTIONS_GHC -fconstraint-solver-iterations=0 #

to the file just makes GHC try forever. Disabling optimization disables the problem.

Steps to reproduce

Unfortunately, this is not minimized in any way and depends on typing plugins.

git clone https://git.tomsmeding.com/ox-arrays
cd ox-arrays
git checkout repro-9.14-branch
rm -f cabal.project.local
rm -rf ~/.cabal/packages/head.hackage.ghc.haskell.org 
cabal update
cabal test -w /home/mikolaj/r/ghc.pre9.14/ghc/_build/stage1/bin/ghc --allow-newer --enable-optimization

Expected behavior

Compiles.

Environment

  • GHC version used: branch ghc-9.14, commit 7b814248

Optional:

  • Operating System: Linux
  • System Architecture: amd64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information