Possibly a variant of "Specialiser creates bogus specialisations" (#23109) that affects 9.4.6
This looks like a repeat of #23109 but for GHC 9.4.6. GHC 9.2.8 is not affected (from the looks of it, GHC 9.2.8 doesn't manage to specialize as much in this case). -O0
is not affected.
The following commit breaks things by making specialization fire more often (as verified with https://hackage.haskell.org/package/inspection-testing)
https://github.com/Mikolaj/horde-ad/commit/85d7ecc5aaaf3775476ca90c049984b444a359d6
The commit doesn't do anything except tweaking SPECIALIZE
pragmas. The unsoundess manifests similarly as in #23109, e.g., with
~/r/horde-ad$ cabal test simplifiedOnlyTest --test-options='-p 3concatBuild22' --enable-optimization -ftest_seq --ghc-options='-dcore-lint -dstg-lint -dcmm-lint -dtag-inference-checks'
Build profile: -w ghc-9.4.6 -O1
In order, the following will be built (use -v for more details):
- horde-ad-0.1.0.0 (test:simplifiedOnlyTest) (first run)
Preprocessing test suite 'simplifiedOnlyTest' for horde-ad-0.1.0.0..
Building test suite 'simplifiedOnlyTest' for horde-ad-0.1.0.0..
Running 1 test suites...
Test suite simplifiedOnlyTest: RUNNING...
Tests for simplified horde-ad
Short_tests
3concatBuild22: FAIL
Exception: fromVector: rank mismatch (9,0)
CallStack (from HasCallStack):
error, called at ./Data/Array/Internal/RankedG.hs:152:45 in orthotope-0.1.6.0-d5eafb3329d4001e31e883540011090b1202463d41446e08b8b1a45899a51b89:Data.Array.Internal.RankedG
fromVector, called at ./Data/Array/Internal/RankedS.hs:133:21 in orthotope-0.1.6.0-d5eafb3329d4001e31e883540011090b1202463d41446e08b8b1a45899a51b89:Data.Array.Internal.RankedS
The following commit reverts a half of the commit above and makes the problem go away.
https://github.com/Mikolaj/horde-ad/commit/eed4f96ddd72e8c97f958196721b42c9fba9e68c
I haven't made any more minimization. I haven't tested with the typing plugins versions that are not yet on Hackage. We don't have -fno-polymorphic-specialisation
in GHC 9.4, so I couldn't test if it prevents the problem.
CC: @christiaanb