Skip to content

Simplifier: Use of zapDemandInfo should probably zap the demand signature instead

While working on #18824 (closed), I found this code https://gitlab.haskell.org/ghc/ghc/-/blob/e0923b98a243809f08245b2ff04ecbe074b55873/compiler/GHC/Core/Opt/Simplify.hs#L959:

    -- Demand info: Note [Setting the demand info]
    -- We also have to nuke demand info if for some reason
    -- eta-expansion *reduces* the arity of the binding to less
    -- than that of the strictness sig. This can happen: see Note [Arity decrease].
    info3 | isEvaldUnfolding new_unf
            || (case dmdSigInfo info2 of
                  DmdSig dmd_ty -> new_arity < dmdTypeDepth dmd_ty)
          = zapDemandInfo info2 `orElse` info2
          | otherwise
          = info2

It looks at the dmdSigInfo and tries to see whether there's an arity decrease. If so, it probably wants to nuke the demand signature. But that is not what zapDemandInfo does; it simply zaps the demandInfo, e.g. how the binding is used. It should probably call the (non-existant) zapDmdSigInfo.

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