Skip to content
  • Richard Eisenberg's avatar
    Simplify treatment of heterogeneous equality · 73a7383e
    Richard Eisenberg authored and Marge Bot's avatar Marge Bot committed
    Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would
    spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for
    a unification. But we needn't do this. Instead, we now spit out
    a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original
    Wanted. This means that we retain the connection between the
    spat-out constraint and the original.
    
    The problem with this new approach is that we cannot use the
    casted equality for substitution; it's too like wanteds-rewriting-
    wanteds. So, we forbid CTyEqCans that mention coercion holes.
    
    All the details are in Note [Equalities with incompatible kinds]
    in TcCanonical.
    
    There are a few knock-on effects, documented where they occur.
    
    While debugging an error in this patch, Simon and I ran into
    infelicities in how patterns and matches are printed; we made
    small improvements.
    
    This patch includes mitigations for #17828, which causes spurious
    pattern-match warnings. When #17828 is fixed, these lines should
    be removed.
    73a7383e