diff options
author | simonpj <unknown> | 1998-06-08 11:45:29 +0000 |
---|---|---|
committer | simonpj <unknown> | 1998-06-08 11:45:29 +0000 |
commit | ba013704bfb94aa133fb28f342e0d432698a5d6d (patch) | |
tree | 4d3ab3a381dcc0a079a5b03189e81b5b4e0779d1 /ghc/compiler/parser/syntax.c | |
parent | b3c6ee0e0185f45d6a9092b5c1f84120c3b8d16d (diff) | |
download | haskell-ba013704bfb94aa133fb28f342e0d432698a5d6d.tar.gz |
[project @ 1998-06-08 11:45:09 by simonpj]
(a) FloatIn idSpecVars bug [DoCon] (b) Generalise superclasses
Diffstat (limited to 'ghc/compiler/parser/syntax.c')
-rw-r--r-- | ghc/compiler/parser/syntax.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/ghc/compiler/parser/syntax.c b/ghc/compiler/parser/syntax.c index 73b39f04bf..4f8d661318 100644 --- a/ghc/compiler/parser/syntax.c +++ b/ghc/compiler/parser/syntax.c @@ -540,9 +540,50 @@ checknobangs(app) hsperror("syntax error: unexpected ! in type"); checknobangs(gtapp((struct Stapp *)app)); - } + } +} + + +/* Check that a type is of the form + C a1 a2 .. an + where n>=1, and the ai are all type variables + This is used to check that a class decl is well formed. +*/ +void +check_class_decl_head_help( app, n ) + ttype app; + int n; /* Number of args so far */ +{ + switch (tttype(app)) { + case tapp: + /* Check the arg is a type variable */ + switch (tttype (gtarg((struct Stapp *) app))) { + case namedtvar: break; + default: hsperror("Class declaration head must use only type variables"); + } + + /* Check the fun part */ + check_class_decl_head_help( gtapp((struct Stapp *) app), n+1 ); + break; + + case tname: + /* Class name; check there is at least one argument */ + if (n==0) { + hsperror("Class must have at least one argument"); + } + break; + + default: + hsperror("Illegal syntax in class declaration head"); + } } +void +check_class_decl_head( app ) + ttype app; +{ check_class_decl_head_help( app, 0 ); } + + /* Splits a tycon application into its constructor and a list of types. |