Skip to content

Possibly a variant of "Specialiser creates bogus specialisations" (#23109) that reproduces with -fno-polymorphic-specialisation on GHC 9.8.1-alpha1

[Edit: see #23923 (comment 524660) for a slightly minimised repro.]

This looks like a repeat of #23109 but even with -fno-polymorphic-specialisation that was so far a sufficient workaround for it (and is the default on 9.8 right now). It seems to follow the same pattern as with the other related issues: as I tweak the code and GHC options to force specializations to happen, tests errors start appearing and gradually appear in greater number.

Repro: with GHC 9.8.1-alpha1 and https://ghc.gitlab.haskell.org/head.hackage/ run (the -O1 or -O2 is essential; tests pass with -O0):

cabal test simplifiedOnlyTest -ftest_seq --enable-optimization --test-show-details=direct --test-options='-p 3concatBuild1'

on commit

https://github.com/Mikolaj/horde-ad/commit/a9ea6e930f3561d90237cf8a431b8aad24387c8e

The test should succeed, but it fails a runtime check (in an outside library) about ranks that the typing guarantees should agree:

    3concatBuild1: 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-479d70a92b172419adf0e1e7dd92abde8158cf52f3d7287680c06fc9bb693f0c:Data.Array.Internal.RankedG
        fromVector, called at ./Data/Array/Internal/RankedS.hs:133:21 in orthotope-0.1.6.0-479d70a92b172419adf0e1e7dd92abde8158cf52f3d7287680c06fc9bb693f0c:Data.Array.Internal.RankedS

I can't compare with GHC 9.6.2 due to #23922 (closed), GHC 9.4.6 fails in exactly the same way (#23866 (closed)), but it fails on several times more tests (after removing --test-options), so the root cause may be different, especially given that GHC 9.4.6 most probably doesn't manage to specialize as much as GHC 9.8.1-alpha1. Adding -fdicts-cheap -flate-dmd-anal -O2 makes GHC 9.8.1-alpha1 fail on 6 instead of 3 tests. A few performance-improving commits ago it wasn't failing at all (but it was failing similarly with -fpolymorphic-specialisation (I don't recall if in exactly the same way)). GHC 9.2.7 is the only recent GHC version that passes this test (and the whole test suite; it compiles quickly and runs quite slowly). IIRC from toying with inspection-testing, GHC 9.2.7 specializes even less than the remaining GHCs.

Edited by Mikolaj Konarski
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information