Skip to content
  • Ryan Scott's avatar
    Use injectiveVarsOfType to catch dodgy type family instance binders (#17008) · 93bed40a
    Ryan Scott authored and Marge Bot's avatar Marge Bot committed
    Previously, we detected dodgy type family instances binders by
    expanding type synonyms (via `exactTyCoVarsOfType`) and looking for
    type variables on the RHS that weren't mentioned on the (expanded)
    LHS. But this doesn't account for type families (like the example
    in #17008), so we instead use `injectiveVarsOfType` to only count
    LHS type variables that are in injective positions. That way, the `a`
    in `type instance F (x :: T a) = a` will not count if `T` is a type
    synonym _or_ a type family.
    
    Along the way, I moved `exactTyCoVarsOfType` to `TyCoFVs` to live
    alongside its sibling functions that also compute free variables.
    
    Fixes #17008.
    93bed40a