[commit: ghc] wip/custom-type-errors: Check that inferred and user-specified types od not mention `TypeError` directly (064875e)
git at git.haskell.org
git at git.haskell.org
Sat Oct 31 20:18:59 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/custom-type-errors
Link : http://ghc.haskell.org/trac/ghc/changeset/064875e5ccddb3c3190c4f03f93763bafad2ef3a/ghc
>---------------------------------------------------------------
commit 064875e5ccddb3c3190c4f03f93763bafad2ef3a
Author: Iavor S. Diatchki <iavor.diatchki at gmail.com>
Date: Sat Oct 31 13:18:44 2015 -0700
Check that inferred and user-specified types od not mention `TypeError` directly
>---------------------------------------------------------------
064875e5ccddb3c3190c4f03f93763bafad2ef3a
compiler/typecheck/TcValidity.hs | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs
index 62449be..3b5d206 100644
--- a/compiler/typecheck/TcValidity.hs
+++ b/compiler/typecheck/TcValidity.hs
@@ -232,6 +232,16 @@ checkAmbiguity ctxt ty
mk_msg ty = pprSigCtxt ctxt (ptext (sLit "the ambiguity check for")) (ppr ty)
ambig_msg = ptext (sLit "To defer the ambiguity check to use sites, enable AllowAmbiguousTypes")
+
+checkUserTypeError :: Type -> TcM ()
+checkUserTypeError = check
+ where
+ check ty
+ | Just (_,msg) <- isUserErrorTy ty = failWithTc (pprUserTypeErrorTy msg)
+ | Just (_,ts) <- splitTyConApp_maybe ty = mapM_ check ts
+ | Just (t1,t2) <- splitAppTy_maybe ty = check t1 >> check t2
+ | otherwise = return ()
+
{-
************************************************************************
* *
@@ -312,6 +322,8 @@ checkValidType ctxt ty
-- the kind of an ill-formed type such as (a~Int)
; check_kind ctxt ty
+ ; checkUserTypeError ty
+
-- Check for ambiguous types. See Note [When to call checkAmbiguity]
-- NB: this will happen even for monotypes, but that should be cheap;
-- and there may be nested foralls for the subtype test to examine
More information about the ghc-commits
mailing list