Commit 638233a7 authored by Robert Griesemer's avatar Robert Griesemer

- don't allow empty decl lists (e.g. const ())

R=r
OCL=16698
CL=16698
parent 44dffd92
...@@ -373,17 +373,11 @@ func (P *Parser) ParseResult() *AST.List { ...@@ -373,17 +373,11 @@ func (P *Parser) ParseResult() *AST.List {
func (P *Parser) ParseFunctionType() *AST.FunctionType { func (P *Parser) ParseFunctionType() *AST.FunctionType {
P.Trace("FunctionType"); P.Trace("FunctionType");
P.OpenScope();
P.level--;
typ := new(AST.FunctionType); typ := new(AST.FunctionType);
typ.pos = P.pos; typ.pos = P.pos;
typ.params = P.ParseParameters(); typ.params = P.ParseParameters();
typ.result = P.ParseResult(); typ.result = P.ParseResult();
P.level++;
P.CloseScope();
P.Ecart(); P.Ecart();
return typ; return typ;
} }
...@@ -1341,6 +1335,8 @@ func (P *Parser) ParseDecl(exported bool, keyword int) *AST.Declaration { ...@@ -1341,6 +1335,8 @@ func (P *Parser) ParseDecl(exported bool, keyword int) *AST.Declaration {
P.Expect(keyword); P.Expect(keyword);
if P.tok == Scanner.LPAREN { if P.tok == Scanner.LPAREN {
P.Next(); P.Next();
decl.decls.Add(P.ParseSpec(exported, keyword));
P.OptSemicolon(Scanner.RPAREN);
for P.tok != Scanner.RPAREN { for P.tok != Scanner.RPAREN {
decl.decls.Add(P.ParseSpec(exported, keyword)); decl.decls.Add(P.ParseSpec(exported, keyword));
P.OptSemicolon(Scanner.RPAREN); P.OptSemicolon(Scanner.RPAREN);
...@@ -1418,7 +1414,9 @@ func (P *Parser) ParseExportDecl() { ...@@ -1418,7 +1414,9 @@ func (P *Parser) ParseExportDecl() {
} }
for P.tok == Scanner.IDENT { for P.tok == Scanner.IDENT {
ident := P.ParseIdent(); ident := P.ParseIdent();
P.Optional(Scanner.COMMA); // TODO this seems wrong if P.tok == Scanner.COMMA {
P.Next(); // TODO this seems wrong
}
} }
if has_paren { if has_paren {
P.Expect(Scanner.RPAREN) P.Expect(Scanner.RPAREN)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment