summaryrefslogtreecommitdiff
path: root/compiler/typecheck/TcHsType.lhs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-06-19 17:26:11 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-06-20 08:16:46 +0100
commit9c621e9b1c7d8a02b48f06f041da605ce27f4d80 (patch)
tree3d4ce53250acf5185924d42f7c02dae5ae8d456b /compiler/typecheck/TcHsType.lhs
parent64224f19d1cccd1104e323016a1481ddaa9db464 (diff)
downloadhaskell-9c621e9b1c7d8a02b48f06f041da605ce27f4d80.tar.gz
Reject forall types in constraints in signatures
Fixes Trac #9196. Thanks to archblob for an initial stab at this. In the end I fixed it in the kind checker rather than the subsequent validity check, (a) so that the error messages look more uniform, and (b) so that I did not need to meddle with isPredTy.
Diffstat (limited to 'compiler/typecheck/TcHsType.lhs')
-rw-r--r--compiler/typecheck/TcHsType.lhs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/typecheck/TcHsType.lhs b/compiler/typecheck/TcHsType.lhs
index 69579ada30..59aafeafba 100644
--- a/compiler/typecheck/TcHsType.lhs
+++ b/compiler/typecheck/TcHsType.lhs
@@ -396,13 +396,17 @@ tc_hs_type hs_ty@(HsAppTy ty1 ty2) exp_kind
(fun_ty, arg_tys) = splitHsAppTys ty1 [ty2]
--------- Foralls
-tc_hs_type hs_ty@(HsForAllTy _ hs_tvs context ty) exp_kind
- = tcHsTyVarBndrs hs_tvs $ \ tvs' ->
+tc_hs_type hs_ty@(HsForAllTy _ hs_tvs context ty) exp_kind@(EK exp_k _)
+ | isConstraintKind exp_k
+ = failWithTc (hang (ptext (sLit "Illegal constraint:")) 2 (ppr hs_ty))
+
+ | otherwise
+ = tcHsTyVarBndrs hs_tvs $ \ tvs' ->
-- Do not kind-generalise here! See Note [Kind generalisation]
do { ctxt' <- tcHsContext context
; ty' <- if null (unLoc context) then -- Plain forall, no context
tc_lhs_type ty exp_kind -- Why exp_kind? See Note [Body kind of forall]
- else
+ else
-- If there is a context, then this forall is really a
-- _function_, so the kind of the result really is *
-- The body kind (result of the function can be * or #, hence ekOpen