diff options
author | Iavor S. Diatchki <iavor.diatchki@gmail.com> | 2015-10-31 13:18:44 -0700 |
---|---|---|
committer | Iavor S. Diatchki <iavor.diatchki@gmail.com> | 2015-10-31 13:18:44 -0700 |
commit | 064875e5ccddb3c3190c4f03f93763bafad2ef3a (patch) | |
tree | 009fe557f1dcdd8f4ac064f40ddbdd7a633bcf78 | |
parent | 65c7b4ddaa5a248a3a87e19f2211f05eef616031 (diff) | |
download | haskell-064875e5ccddb3c3190c4f03f93763bafad2ef3a.tar.gz |
Check that inferred and user-specified types od not mention `TypeError` directly
-rw-r--r-- | compiler/typecheck/TcValidity.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs index 62449beaa4..3b5d206a67 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 |