Skip to content
  • Simon Peyton Jones's avatar
    Fix isDroppableCt (Trac #14763) · 6edafe3b
    Simon Peyton Jones authored
    When finishing up an implication constraint, it's a bit tricky to
    decide which Derived constraints to retain (for error reporting) and
    which to discard.  I got this wrong in commit
       f20cf982
       (Remove wc_insol from WantedConstraints)
    
    The particular problem in Trac #14763 was that we were reporting as an
    error a fundep-generated constraint
      (ex ~ T)
    where 'ex' is an existentially-bound variable in a pattern match.
    But this isn't really an error at all.
    
    This patch fixes the problem. Indeed, since I had to understand
    this rather tricky code, I took the opportunity to clean it up
    and document better.  See
      isDroppableCt :: Ct -> Bool
    and Note [Dropping derived constraints]
    
    I also removed wl_deriv altogether from the WorkList data type.  It
    was there in the hope of gaining efficiency by not even processing
    lots of derived constraints, but it has turned out that most derived
    constraints (notably equalities) must be processed anyway; see
    Note [Prioritise equalities] in TcSMonad.
    
    The two are coupled because to decide which constraints to put in
    wl_deriv I was using another variant of isDroppableCt.  Now it's much
    simpler -- and perhaps even more efficient too.
    6edafe3b