aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-25 10:03:26 -0500
committerGitHub <noreply@github.com>2018-01-25 10:03:26 -0500
commitf7670882aff5fb3a943057edd9da34d053b5fe59 (patch)
tree7fa2c7f06331feaad43ba63b0969add120633d49 /src/parser.cpp
parente5bc5873d74713bedbc32817ed31370c3256418d (diff)
parent3671582c15235e5f79a84936ea2f834f6968ff8c (diff)
downloadzig-f7670882aff5fb3a943057edd9da34d053b5fe59.tar.gz
zig-f7670882aff5fb3a943057edd9da34d053b5fe59.zip
Merge pull request #720 from zig-lang/require-return-type
syntax: functions require return type. remove `->`
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 3439ec0c54..12293bc61b 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -84,11 +84,6 @@ static AstNode *ast_create_node(ParseContext *pc, NodeType type, Token *first_to
return node;
}
-static AstNode *ast_create_void_type_node(ParseContext *pc, Token *token) {
- AstNode *node = ast_create_node(pc, NodeTypeSymbol, token);
- node->data.symbol_expr.symbol = pc->void_buf;
- return node;
-}
static void parse_asm_template(ParseContext *pc, AstNode *node) {
Buf *asm_template = node->data.asm_expr.asm_template;
@@ -2245,7 +2240,7 @@ static AstNode *ast_parse_block(ParseContext *pc, size_t *token_index, bool mand
}
/*
-FnProto = option("nakedcc" | "stdcallcc" | "extern") "fn" option(Symbol) ParamDeclList option("align" "(" Expression ")") option("section" "(" Expression ")") option("-&gt;" TypeExpr)
+FnProto = option("nakedcc" | "stdcallcc" | "extern") "fn" option(Symbol) ParamDeclList option("align" "(" Expression ")") option("section" "(" Expression ")") TypeExpr
*/
static AstNode *ast_parse_fn_proto(ParseContext *pc, size_t *token_index, bool mandatory, VisibMod visib_mod) {
Token *first_token = &pc->tokens->at(*token_index);
@@ -2320,12 +2315,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc, size_t *token_index, bool m
ast_eat_token(pc, token_index, TokenIdRParen);
next_token = &pc->tokens->at(*token_index);
}
- if (next_token->id == TokenIdArrow) {
- *token_index += 1;
- node->data.fn_proto.return_type = ast_parse_type_expr(pc, token_index, false);
- } else {
- node->data.fn_proto.return_type = ast_create_void_type_node(pc, next_token);
- }
+ node->data.fn_proto.return_type = ast_parse_type_expr(pc, token_index, true);
return node;
}