expandTypeSynonyms panics after kind equality patch

Ömer Sinan Ağacan omeragacan at gmail.com
Wed Jan 6 16:33:50 UTC 2016

My branch panicking during stage 2 build and when I tried to debug I realized
the panicking function is `unionTCvSubst`, when called by `expandTypeSynonyms`.
In my branch I'm doing some type-based transformations and I'm using
`expandTypeSynonyms` on type of identifiers for that.

According to git blame logs, the function `unionTCvSubst` was added with kind
equality patch. The patch made this change in `expandTypeSynonyms`:

    -      = go (mkAppTys (substTy (mkTopTvSubst tenv) rhs) tys')
    +      = let subst' = unionTCvSubst subst (mkTopTCvSubst tenv) in
    +        go subst' (mkAppTys rhs tys')

Which is what's causing the panic. The exact place it's panicking during the
stage2 build is when I call `expandTypeSynonyms` on type `TvSubstEnv` (i.e. in
my transformation I get type of an id and it turns out to be TvSubstEnv, when I
call `expandTypeSynonyms` on this type it panics)

I figured this much but I don't understand type system details, so, does anyone
here have any ideas what's going wrong here? Richard?

Note that this panic happens even though I don't do any changes in types - I'm
just looking at the types for some transformations but no changes on the types
are done.

More information about the ghc-devs mailing list