diff options
| author | Josh Wolfe <thejoshwolfe@gmail.com> | 2017-04-02 12:46:18 -0700 |
|---|---|---|
| committer | Josh Wolfe <thejoshwolfe@gmail.com> | 2017-04-02 12:46:18 -0700 |
| commit | 136a9a9d6b657e29680ca53f158f46eb5b92e9e7 (patch) | |
| tree | 08dbb09049745d9b2529dd5bf33394632b3b3eb0 /src | |
| parent | 4b9e782d37a334740a04190e3b3dd375f41ef3fe (diff) | |
| download | zig-136a9a9d6b657e29680ca53f158f46eb5b92e9e7.tar.gz zig-136a9a9d6b657e29680ca53f158f46eb5b92e9e7.zip | |
variable declarations must be followed by semicolon
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 47abebe50d..77a358376b 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1598,8 +1598,6 @@ static AstNode *ast_parse_variable_declaration_expr(ParseContext *pc, size_t *to *token_index += 1; if (eq_or_colon->id == TokenIdEq) { node->data.variable_declaration.expr = ast_parse_expression(pc, token_index, true); - - return node; } else if (eq_or_colon->id == TokenIdColon) { node->data.variable_declaration.type = ast_parse_type_expr(pc, token_index, true); Token *eq_token = &pc->tokens->at(*token_index); @@ -1608,11 +1606,15 @@ static AstNode *ast_parse_variable_declaration_expr(ParseContext *pc, size_t *to node->data.variable_declaration.expr = ast_parse_expression(pc, token_index, true); } - - return node; } else { ast_invalid_token_error(pc, eq_or_colon); } + + // peek ahead and ensure that all variable declarations are followed by a semicolon + Token *semicolon_token = &pc->tokens->at(*token_index); + ast_expect_token(pc, semicolon_token, TokenIdSemicolon); + + return node; } /* |
