From 0dfaeb66fb8457e7339abbd44d5c53a81ad8ae3a Mon Sep 17 00:00:00 2001
From: Simon Peyton Jones <simon.peytonjones@gmail.com>
Date: Mon, 7 Oct 2024 15:56:12 +0100
Subject: [PATCH] Wibbles

---
 compiler/GHC/Tc/Errors.hs           |  2 ++
 compiler/GHC/Tc/Types/Constraint.hs | 14 +++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/compiler/GHC/Tc/Errors.hs b/compiler/GHC/Tc/Errors.hs
index 8379202af0a..ce325b285db 100644
--- a/compiler/GHC/Tc/Errors.hs
+++ b/compiler/GHC/Tc/Errors.hs
@@ -470,6 +470,8 @@ mkErrorItem ct
              flav = ctFlavour ct
 
        ; (suppress, m_evdest) <- case ctEvidence ct of
+         -- For this `suppress` stuff
+         -- see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint
            CtGiven {} -> return (False, Nothing)
            CtWanted { ctev_rewriters = rewriters, ctev_dest = dest }
              -> do { rewriters' <- zonkRewriterSet rewriters
diff --git a/compiler/GHC/Tc/Types/Constraint.hs b/compiler/GHC/Tc/Types/Constraint.hs
index 6816f80428d..26e0d694fb5 100644
--- a/compiler/GHC/Tc/Types/Constraint.hs
+++ b/compiler/GHC/Tc/Types/Constraint.hs
@@ -1459,13 +1459,13 @@ can't be solved.  But not quite all such constraints; see wrinkles.
    it looks only for IrredCt; all insoluble constraints oare put into
    CIrredCan
 
-(IW2) We only treat it as insoluble if it has an empty rewriter set.
-   Otherwise #25325 happens: a Wanted constraint A that is /not/ insoluble
-   rewrites some other Wanted constraint B, so B has A in its rewriter
-   set.  Now B looks insoluble.  The danger is that we'll suppress reporting
-   B becuase of its empty rewriter set; and suppress reporting A because
-   there is an insoluble B lying around.  (This suppression happens in
-   GHC.Tc.Errors.)  Solution: don't treat B as insoluble.
+(IW2) We only treat it as insoluble if it has an empty rewriter set.  (See Note
+   [Wanteds rewrite Wanteds].)  Otherwise #25325 happens: a Wanted constraint A
+   that is /not/ insoluble rewrites some other Wanted constraint B, so B has A
+   in its rewriter set.  Now B looks insoluble.  The danger is that we'll
+   suppress reporting B becuase of its empty rewriter set; and suppress
+   reporting A because there is an insoluble B lying around.  (This suppression
+   happens in GHC.Tc.Errors.mkErrorItem.)  Solution: don't treat B as insoluble.
 
 (IW3) If the Wanted arises from a Given (how can that happen?), don't
    treat it as a Wanted insoluble (obviously).
-- 
GitLab