[Git][ghc/ghc][master] Assert that ctEvCoercion is called on an equality
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Thu Oct 31 12:39:46 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
0b11cdc0 by sheaf at 2024-10-31T08:38:55-04:00
Assert that ctEvCoercion is called on an equality
Calling 'ctEvCoercion' on non-equality constraints is always incorrect.
We add an assertion to this function to detect such cases; for example
a type-checking plugin might erroneously do this.
- - - - -
1 changed file:
- compiler/GHC/Tc/Types/Constraint.hs
Changes:
=====================================
compiler/GHC/Tc/Types/Constraint.hs
=====================================
@@ -2306,8 +2306,10 @@ ctEvExpr ev@(CtWanted { ctev_dest = HoleDest _ })
ctEvExpr ev = evId (ctEvEvId ev)
ctEvCoercion :: HasDebugCallStack => CtEvidence -> TcCoercion
-ctEvCoercion (CtGiven { ctev_evar = ev_id })
- = mkCoVarCo ev_id
+ctEvCoercion _given@(CtGiven { ctev_evar = ev_id })
+ = assertPpr (isCoVar ev_id)
+ (text "ctEvCoercion used on non-equality Given constraint:" <+> ppr _given)
+ $ mkCoVarCo ev_id
ctEvCoercion (CtWanted { ctev_dest = dest })
| HoleDest hole <- dest
= -- ctEvCoercion is only called on type equalities
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b11cdc022ce33d089db95b2b2e7c1f4bb326d37
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b11cdc022ce33d089db95b2b2e7c1f4bb326d37
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/20241031/defc410e/attachment.html>
More information about the ghc-commits
mailing list