Skip to content

Redundant constraints improvement, incl. redundant quantified constraints

Richard Eisenberg requested to merge wip/T20602 into master

This patch fixes #20602 (closed) and #20582 (closed).

Use local instances with least superclass depth

See new Note [Use only the best local instance] in
GHC.Tc.Solver.Interact.

Close #20582.

and

Improve redundant-constraints warning

Previously, we reported things wrong with

  f :: (Eq a, Ord a) => a -> Bool
  f x = x == x

saying that Eq a was redundant. This is fixed now, along with
some simplification in Note [Replacement vs keeping]. There's
a tiny bit of extra complexity in setImplicationStatus, but
it's explained in Note [Tracking redundant constraints].

Close #20602

Both fixes use the same underlying mechanism around superclass depth, so they arrive together.

Merge request reports