summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>2006-09-15 21:04:28 +0000
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>2006-09-15 21:04:28 +0000
commitbd865113a1446bb18fb32b546b8776b846a23116 (patch)
tree9ddc4956a87bc48cb69585ce563d1baba2fab458 /compiler/parser
parent7f7be6d1bb33393c1d384923fe938b7c10acbeec (diff)
downloadhaskell-bd865113a1446bb18fb32b546b8776b846a23116.tar.gz
Added error checks & fixed bugs
Thu Aug 3 19:29:38 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Added error checks & fixed bugs
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/Parser.y.pp1
-rw-r--r--compiler/parser/RdrHsSyn.lhs14
2 files changed, 14 insertions, 1 deletions
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index 3951128476..4548221955 100644
--- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -470,6 +470,7 @@ cl_decl :: { LTyClDecl RdrName }
cvBindsAndSigs (unLoc $4)
; (ctxt, tc, tvs, tparms) = unLoc $2}
; checkTyVars tparms False -- only type vars allowed
+ ; checkKindSigs ats
; return $ L (comb4 $1 $2 $3 $4)
(mkClassDecl (ctxt, tc, tvs)
(unLoc $3) sigs binds ats) } }
diff --git a/compiler/parser/RdrHsSyn.lhs b/compiler/parser/RdrHsSyn.lhs
index 980c7f754a..a8449ae22d 100644
--- a/compiler/parser/RdrHsSyn.lhs
+++ b/compiler/parser/RdrHsSyn.lhs
@@ -38,6 +38,7 @@ module RdrHsSyn (
checkTyClHdr, -- LHsContext RdrName -> LHsType RdrName -> P (LHsContext RdrName, Located RdrName, [LHsTyVarBndr RdrName], [LHsType RdrName])
checkTyVars, -- [LHsType RdrName] -> Bool -> P ()
checkSynHdr, -- LHsType RdrName -> P (Located RdrName, [LHsTyVarBndr RdrName], Maybe [LHsType RdrName])
+ checkKindSigs, -- [LTyClDecl RdrName] -> P ()
checkTopTypeD, -- LTyClDecl RdrName -> P (HsDecl RdrName)
checkInstType, -- HsType -> P HsType
checkPattern, -- HsExp -> P HsPat
@@ -213,7 +214,7 @@ cvBindsAndSigs :: OrdList (LHsDecl RdrName)
-> (Bag (LHsBind RdrName), [LSig RdrName], [LTyClDecl RdrName])
-- Input decls contain just value bindings and signatures
-- and in case of class or instance declarations also
--- associated data or synonym definitions
+-- associated type declarations
cvBindsAndSigs fb = go (fromOL fb)
where
go [] = (emptyBag, [], [])
@@ -506,6 +507,17 @@ extractTyVars tvs = collects [] tvs
tvs' <- collects tvs ts
collect tvs' t
+-- Check that associated type declarations of a class are all kind signatures.
+--
+checkKindSigs :: [LTyClDecl RdrName] -> P ()
+checkKindSigs = mapM_ check
+ where
+ check (L l tydecl)
+ | isKindSigDecl tydecl
+ || isSynDecl tydecl = return ()
+ | otherwise =
+ parseError l "Type declaration in a class must be a kind signature or synonym default"
+
-- Wrap a toplevel type or data declaration into 'TyClD' and ensure for
-- data declarations that all type parameters are variables only (which is in
-- contrast to type functions and associated type declarations).