authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-04-02 13:01:23-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-04-02 13:01:23-07:00
loge3c796258c766d5de857ce37eeb3bdc5bb353e68
tree9d48e59fec35568758c903d3197e7604e19ec0c8
parent136a9a9d6b657e29680ca53f158f46eb5b92e9e7

allow implicit semicolon after defer {}


1 files changed, 12 insertions(+), 12 deletions(-)

src/parser.cpp+12-12
......@@ -1856,7 +1856,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo
18561856 }
18571857}
18581858
1859static bool block_expr_has_block_body(AstNode *node) {
1859static bool statement_has_block_body(AstNode *node) {
18601860 switch (node->type) {
18611861 case NodeTypeIfBoolExpr:
18621862 if (node->data.if_bool_expr.else_node)
......@@ -1879,6 +1879,8 @@ static bool block_expr_has_block_body(AstNode *node) {
18791879 return true;
18801880 case NodeTypeCompTime:
18811881 return node->data.comptime_expr.expr->type == NodeTypeBlock;
1882 case NodeTypeDefer:
1883 return node->data.defer.expr->type == NodeTypeBlock;
18821884 default:
18831885 zig_unreachable();
18841886 }
......@@ -2123,18 +2125,16 @@ static AstNode *ast_parse_block(ParseContext *pc, size_t *token_index, bool mand
21232125 statement_node = ast_parse_variable_declaration_expr(pc, token_index, false, VisibModPrivate);
21242126 if (!statement_node) {
21252127 statement_node = ast_parse_defer_expr(pc, token_index);
2126 if (!statement_node) {
2128 if (!statement_node)
21272129 statement_node = ast_parse_block_expr(pc, token_index, false);
2128 if (statement_node) {
2129 if (block_expr_has_block_body(statement_node)) {
2130 semicolon_expected = false;
2131 }
2132 } else {
2133 statement_node = ast_parse_expression(pc, token_index, false);
2134 if (!statement_node) {
2135 // final semicolon means add a void statement.
2136 need_implicit_final_void_statement = true;
2137 }
2130 if (statement_node) {
2131 if (statement_has_block_body(statement_node))
2132 semicolon_expected = false;
2133 } else {
2134 statement_node = ast_parse_expression(pc, token_index, false);
2135 if (!statement_node) {
2136 // final semicolon means add a void statement.
2137 need_implicit_final_void_statement = true;
21382138 }
21392139 }
21402140 }