aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorJosh Wolfe <thejoshwolfe@gmail.com>2017-04-02 13:18:12 -0700
committerJosh Wolfe <thejoshwolfe@gmail.com>2017-04-02 13:18:12 -0700
commit8d03d666af1b8b14e6702c2502846e3c1a79e9da (patch)
tree2b76c08c09b0ae707619bfb20449210bd45f27eb /src/parser.cpp
parente3c796258c766d5de857ce37eeb3bdc5bb353e68 (diff)
downloadzig-8d03d666af1b8b14e6702c2502846e3c1a79e9da.tar.gz
zig-8d03d666af1b8b14e6702c2502846e3c1a79e9da.zip
add secret void expression after defer statement if it's the last statement in a block
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index bc08bd84b7..a63464dbe5 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -2125,8 +2125,12 @@ static AstNode *ast_parse_block(ParseContext *pc, size_t *token_index, bool mand
statement_node = ast_parse_variable_declaration_expr(pc, token_index, false, VisibModPrivate);
if (!statement_node) {
statement_node = ast_parse_defer_expr(pc, token_index);
- if (!statement_node)
+ if (statement_node) {
+ // don't let defer be the last statement in a block
+ need_implicit_final_void_statement = true;
+ } else {
statement_node = ast_parse_block_expr(pc, token_index, false);
+ }
if (statement_node) {
if (statement_has_block_body(statement_node))
semicolon_expected = false;