Permalink
Browse files

Fix Trac #7805: don't allow nested foralls in promoted types

  • Loading branch information...
1 parent 1128f1e commit 7501a2c3a181a53789e4f4462847295354042849 @simonpj simonpj committed Apr 3, 2013
Showing with 9 additions and 14 deletions.
  1. +9 −14 compiler/typecheck/TcTyDecls.lhs
@@ -506,21 +506,16 @@ isPromotableType :: NameSet -> Type -> Bool
-- Must line up with DataCon.promoteType
-- But the function lives here because we must treat the
-- *recursive* tycons as promotable
-isPromotableType rec_tcs ty
- = case splitForAllTys ty of
- (_, rho) -> go rho
+isPromotableType rec_tcs con_arg_ty
+ = go con_arg_ty
where
- go (TyConApp tc tys)
- | tys `lengthIs` tyConArity tc
- , tyConName tc `elemNameSet` rec_tcs
- || isJust (promotableTyCon_maybe tc)
- = all go tys
- | otherwise = False
- go (FunTy arg res) = go arg && go res
- go (AppTy arg res) = go arg && go res
- go (ForAllTy _ ty) = go ty
- go (TyVarTy {}) = True
- go (LitTy {}) = False
+ go (TyConApp tc tys) = tys `lengthIs` tyConArity tc
+ && (tyConName tc `elemNameSet` rec_tcs
+ || isJust (promotableTyCon_maybe tc))
+ && all go tys
+ go (FunTy arg res) = go arg && go res
+ go (TyVarTy {}) = True
+ go _ = False
\end{code}

0 comments on commit 7501a2c

Please sign in to comment.