[Git][ghc/ghc][wip/T24978] 2 commits: Do proper eqType in findMatchingIrreds

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Mon Jul 1 14:50:21 UTC 2024



Simon Peyton Jones pushed to branch wip/T24978 at Glasgow Haskell Compiler / GHC


Commits:
e4206ce6 by Simon Peyton Jones at 2024-07-01T15:38:17+01:00
Do proper eqType in findMatchingIrreds

I believe that the four calls of `tcEqTypeNoKindCheck` in match_eq_help are
bogus; they should be `tcEqType`.

The use of `tcEqTypeNoKindCheck` in `match_non_eq` is fine, I think, because
`irred` and `irredCtPred` both have type Constraint.

Actually even that isn't really true.  One might have kind Constraint and the
other kind Constraint#.  E.g.  (a b ~# c d) and (E q ) Maybe that is another
bug?

Richard replies: Yes I think you're probably right. I could see some ill-typed
Core potentially being produced in this way. I think the check for non_eq is OK:
I don't think a Constraint# is going to match a regular irred. But maybe it's
safer to change it.

- - - - -
e4d078ab by Simon Peyton Jones at 2024-07-01T15:49:48+01:00
Fix egregious bug

- - - - -


2 changed files:

- compiler/GHC/Builtin/Types/Literals.hs
- compiler/GHC/Tc/Solver/InertSet.hs


Changes:

=====================================
compiler/GHC/Builtin/Types/Literals.hs
=====================================
@@ -168,9 +168,9 @@ tryMatchFam :: BuiltInSynFamily -> [Type]
 --              :: F tys ~r rhs,
 tryMatchFam builtin_fam arg_tys
   = listToMaybe $   -- Pick first rule to match
-    [ (BuiltInFamRewrite rw_ax, [inst_tys], res_ty)
+    [ (BuiltInFamRewrite rw_ax, inst_tys, res_ty)
     | rw_ax <- sfMatchFam builtin_fam
-    , Just ([inst_tys],res_ty) <- [bifrw_match rw_ax arg_tys] ]
+    , Just (inst_tys,res_ty) <- [bifrw_match rw_ax arg_tys] ]
 
 -------------------------------------------------------------------------------
 --          Constructing BuiltInFamInteract, BuiltInFamRewrite


=====================================
compiler/GHC/Tc/Solver/InertSet.hs
=====================================
@@ -1443,8 +1443,8 @@ findMatchingIrreds irreds ev
   where
     pred = ctEvPred ev
     match_non_eq irred
-      | irredCtPred irred `tcEqTypeNoKindCheck` pred = Left (irred, NotSwapped)
-      | otherwise                                    = Right irred
+      | irredCtPred irred `tcEqType` pred = Left (irred, NotSwapped)
+      | otherwise                         = Right irred
 
     match_eq eq_rel1 lty1 rty1 irred
       | EqPred eq_rel2 lty2 rty2 <- classifyPredType (irredCtPred irred)
@@ -1455,9 +1455,9 @@ findMatchingIrreds irreds ev
       = Right irred
 
     match_eq_help lty1 rty1 lty2 rty2
-      | lty1 `tcEqTypeNoKindCheck` lty2, rty1 `tcEqTypeNoKindCheck` rty2
+      | lty1 `tcEqType` lty2, rty1 `tcEqType` rty2
       = Just NotSwapped
-      | lty1 `tcEqTypeNoKindCheck` rty2, rty1 `tcEqTypeNoKindCheck` lty2
+      | lty1 `tcEqType` rty2, rty1 `tcEqType` lty2
       = Just IsSwapped
       | otherwise
       = Nothing



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5210eaa37f8f6fe8f3d6eacb8d34514ed5b3560...e4d078abb7c84a099c09f54a87669bc3e2a14138

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5210eaa37f8f6fe8f3d6eacb8d34514ed5b3560...e4d078abb7c84a099c09f54a87669bc3e2a14138
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240701/646a7c79/attachment-0001.html>


More information about the ghc-commits mailing list