Skip to content

`ghc-debug-common-0.3.0.0` build failure on GHC 9.4

Attempting to build ghc-debug-common-0.3.0.0 on GHC 9.4.2 fails with:

[6 of 9] Compiling GHC.Debug.Decode.Convert ( src/GHC/Debug/Decode/Convert.hs, dist/build/GHC/Debug/Decode/Convert.o, dist/build/GHC/Debug/Decode/Convert.dyn_o )

src/GHC/Debug/Decode/Convert.hs:53:38: error:
    • Couldn't match type ‘a’ with ‘Maybe a’
      Expected: Maybe a
        Actual: Maybe (Maybe a)
      ‘a’ is a rigid type variable bound by
        the type signature for:
          convertClosure :: forall a.
                            (Num a, Eq a, Show a) =>
                            StgInfoTableWithPtr
                            -> GHC.GenClosure a -> DebugClosure Void InfoTablePtr Void a
        at src/GHC/Debug/Decode/Convert.hs:12:1-123
    • In the sixth argument of ‘WeakClosure’, namely ‘w_link’
      In the expression: WeakClosure itb a2 a3 a4 a5 w_link
      In the expression:
        let w_link = if a6 == 0 then Nothing else Just a6
        in WeakClosure itb a2 a3 a4 a5 w_link
    • Relevant bindings include
        w_link :: Maybe (Maybe a)
          (bound at src/GHC/Debug/Decode/Convert.hs:49:11)
        a6 :: Maybe a (bound at src/GHC/Debug/Decode/Convert.hs:44:35)
        a5 :: a (bound at src/GHC/Debug/Decode/Convert.hs:44:32)
        a4 :: a (bound at src/GHC/Debug/Decode/Convert.hs:44:29)
        a3 :: a (bound at src/GHC/Debug/Decode/Convert.hs:44:26)
        a2 :: a (bound at src/GHC/Debug/Decode/Convert.hs:44:23)
        (Some bindings suppressed; use -fmax-relevant-binds=N or -fno-max-relevant-binds)
   |
53 |       in WeakClosure itb a2 a3 a4 a5 w_link
   |                                      ^^^^^^

The build succeeds on GHC 9.2 and earlier. I think the culprit is this code:

#if __GLASGOW_HASKELL__ >= 905
      let w_link = a6
#else
      -- nullPtr check
      let w_link = if a6 == 0
                  then Nothing
                  else Just a6
#endif

I believe that >= 905 should be >= 904 instead.