Skip to content

Suspicious zipping in TyCoRep

TyCoRep contains the following pattern:

zipTvSubst :: [TyVar] -> [Type] -> TCvSubst
zipTvSubst tvs tys
  | debugIsOn
  , not (all isTyVar tvs) || neLength tvs tys
  = pprTrace "zipTvSubst" (ppr tvs $$ ppr tys) emptyTCvSubst
  | otherwise
  = mkTvSubst (mkInScopeSet (tyCoVarsOfTypes tys)) tenv
  where
    tenv = zipTyEnv tvs tys

(same with zipCvSubst, zipTCvSubst).

This is suspicious; if tvs and tys happen to have different lengths, we're returning emptyTCvSubst and writing a trace message. zipTyEnv and zipCoEnv are checking that the argument lengths are equal. So this extra check is converting a possible assert failure to a silent emptyTCvSubst.

I've tried converting pprTrace to pprPanic and got a panic when compiling GHC: https://circleci.com/gh/tweag/ghc/3555.

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