Skip to content

Simplifier zaps Deadness on field binders of a DataAlt

Consider

foo = getLine >> getLine

This will produce in -dddump-simpl

Lib.foo1
  = \ (s_aAT :: GHC.Prim.State# GHC.Prim.RealWorld) ->
      case GHC.Internal.IO.Handle.Internals.wantReadableHandle_1
             @String
             GHC.Internal.IO.Handle.Text.hGetLine3
             GHC.Internal.IO.Handle.FD.stdin
             (GHC.Internal.IO.Handle.Text.hGetLine2
              `cast` (<GHC.Internal.IO.Handle.Types.Handle__>_R
                      %<Many>_N ->_R Sym (GHC.Types.N:IO[0] <String>_R)
                      :: (GHC.Internal.IO.Handle.Types.Handle__
                          -> GHC.Prim.State# GHC.Prim.RealWorld
                          -> (# GHC.Prim.State# GHC.Prim.RealWorld, String #))
                         ~R# (GHC.Internal.IO.Handle.Types.Handle__ -> IO String)))
             s_aAT
      of
      { (# ipv_aAV, ipv1_aAW #) ->
      GHC.Internal.IO.Handle.Text.hGetLine1
        GHC.Internal.IO.Handle.FD.stdin ipv_aAV
      }

NB: ipv1_aAW is dead, but not annotated as such. (I also checked isDeadBinder, which was False, to be sure this is not just some pretty-printing misconfiguration.)

This seems like an oversight and bit me in !12573 (closed).

Cure

Investigation points to the Simplifier dropping the OccInfo upon cloning the field binders in the DataAlt case of simplAlt. Perhaps we can fix it to transfer deadness, at least.

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