diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-06-12 16:58:25 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-06-12 16:58:25 +0100 |
| commit | e6a206a430ab034d2a1b3b60577639b75e90cbbe (patch) | |
| tree | 7360c1518aca3e39c6e33a1f3284219c35520af6 /src/parser.cpp | |
| parent | f52a1e4ded0f6cffb8722ec510a18f09718ba00a (diff) | |
Check for empty generic declaration list
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index c96070044..a5dead4ce 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -2567,11 +2567,19 @@ AstNode *parse_gen_decl(AstFile *f, Token token, ParseSpecFunc *func) { expect_semicolon(f, spec); } close = expect_token(f, Token_CloseParen); + if (f->curr_token.pos.line == close.pos.line || + open.pos.line == close.pos.line) { + expect_semicolon(f, NULL); + } } else { array_init(&specs, heap_allocator(), 1); array_add(&specs, func(f, token)); } + if (specs.count == 0) { + syntax_error(token, "Empty %.*s declaration list", LIT(token_strings[token.kind])); + } + AstNode *decl = ast_gen_decl(f, token, open, close, specs); if (token.kind == Token_let) { decl->GenDecl.flags |= VarDeclFlag_immutable; @@ -2790,7 +2798,6 @@ AstNode *parse_decl(AstFile *f) { Token token = f->curr_token; next_token(f); - return parse_gen_decl(f, token, func); } |