Skip to content

Eta reduction/expansion loop

In the build log for HEAD today you'll see:

WARNING: file compiler\simplCore\SimplCore.hs, line 604
  Simplifier bailing out after 10 iterations [148, 4, 4, 4, 4, 4, 4, 4, 4, 4]
    Size = {terms: 290, types: 237, coercions: 56}

when compilingData/ByteString/Builder/Prim/Internal/Floating.hs.

There is a loop here: in each simplifier pass we get an eta-expansion and an eta reduction, which cancel each other out. This is bad.

Here is the offending snippet of code

((bindIO @ () @ ()
    ($fStorableDouble_$cpoke
       (castPtr @ Word8 @ Double op)
       x)
    ((\ (ds :: ()) ->
        (\ (eta_B1 :: State# RealWorld) ->
           (k `cast` (NTCo:IO[0] <()>_R
                     :: IO ()
                        ~R# (State# RealWorld -> (# State# RealWorld, () #))))
            eta_B1)
        `cast` (Sym (NTCo:IO[0] <()>_R)
                :: (State# RealWorld -> (# State# RealWorld, () #))
                   ~R# IO ()))
     `cast` (<()>_R
             -> NTCo:IO[0] <()>_R ; Sym (NTCo:IO[0] <()>_R)
             :: (() -> IO ()) ~R# (() -> IO ()))))
 `cast` (NTCo:IO[0] <()>_R
         :: IO () ~R# (State# RealWorld -> (# State# RealWorld, () #))))

At this point k is in scope with arity 1. Actually its binding is

k :: IO ()
k = bindIO @ Word64 @ () a_s2As a_s2Au

I'm not precisely sure why this goes wrong, but it's very clearly bogus, so I'm opening a ticket to keep track.

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