[commit: ghc] master: Add role-checking ASSERT to mkCast (3ac1539)
git at git.haskell.org
git at git.haskell.org
Wed Nov 27 15:02:56 UTC 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/3ac1539cfa1745ef5133fc5747095deb0c1d795d/ghc
>---------------------------------------------------------------
commit 3ac1539cfa1745ef5133fc5747095deb0c1d795d
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Wed Nov 27 10:33:56 2013 +0000
Add role-checking ASSERT to mkCast
>---------------------------------------------------------------
3ac1539cfa1745ef5133fc5747095deb0c1d795d
compiler/coreSyn/CoreUtils.lhs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/compiler/coreSyn/CoreUtils.lhs b/compiler/coreSyn/CoreUtils.lhs
index 8f7b777..91f68a2 100644
--- a/compiler/coreSyn/CoreUtils.lhs
+++ b/compiler/coreSyn/CoreUtils.lhs
@@ -190,7 +190,9 @@ applyTypeToArgs e op_ty args
-- | Wrap the given expression in the coercion safely, dropping
-- identity coercions and coalescing nested coercions
mkCast :: CoreExpr -> Coercion -> CoreExpr
-mkCast e co | isReflCo co = e
+mkCast e co | ASSERT2 ( coercionRole co == Representational
+ , ptext (sLit "coercion") <+> ppr co <+> ptext (sLit "passed to mkCast") <+> ppr e <+> ptext (sLit "has wrong role") <+> ppr (coercionRole co) )
+ isReflCo co = e
mkCast (Coercion e_co) co
| isCoVarType (pSnd (coercionKind co))
More information about the ghc-commits
mailing list