Skip to content

`mkEtaWW` warns on Haddock's `reparenTyVar` function

When a validate build compiles Haddock, I get the usual wall of warnings, but this one stood out as odd to me:

WARNING:
  mkEtaWW
  [,] HsTyVarBndr () a_shQQ
  $wreparenTyVar
    @a_shQQ
    @()
    @~(ww_shQV :: XParTy a_shQQ ~# EpAnn AnnParen)
    @~(ww1_shQZ :: NoGhcTc a_shQQ ~# a_shQQ)
    ww2_slp1
    ww3_slp2
    ww4_slp3
    eta1_slp8
  Call stack:
      CallStack (from HasCallStack):
        warnPprTrace, called at compiler/GHC/Core/Opt/Arity.hs:1625:10 in ghc:GHC.Core.Opt.Arity

And this is the definition of reparenTyVar:

-- | Add parenthesis around the types in a 'HsTyVarBndr' (see 'reparenTypePrec')
reparenTyVar :: (XRecCond a) => HsTyVarBndr flag a -> HsTyVarBndr flag a
reparenTyVar (UserTyVar x flag n) = UserTyVar x flag n
reparenTyVar (KindedTyVar x flag n kind) = KindedTyVar x flag n (reparenLType kind)
reparenTyVar v@XTyVarBndr{} = v

Where XRecCond probably carries some rather intricate TTG evidence.

Mapping back the warning output to the code in mkEtaWW

warnPprTrace True "mkEtaWW" ((ppr orig_oss <+> ppr orig_ty) $$ ppr_orig_expr)

, I think orig_oss simply outputs [,], which the pretty-printed output of [NoOneShotInfo, NoOneShotInfo]. The orig_ty is (a specialisation of) the result type of reparenTyVar, HsTyVarBndr flag a. The latter clearly is not an arrow type. Neither are there any unsafe coerces that might have led to this type error.

So I ask: Why do we get a "type error" here? (In the sense that the arity type clearly says "two more non-oneshot lambdas", whereas the orig_ty type simply isn't an arrow type.) Would we expect the warning to trigger for this code? I certainly did not.

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