summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index 37bf68e..4fc10e3 100644
--- a/parse.c
+++ b/parse.c
@@ -2448,17 +2448,23 @@ static Status parse_stmt(Parser *p, Statement *s, bool *was_a_statement) {
return false;
}
goto success;
- case KW_DEFER:
+ case KW_DEFER: {
if (p->block == NULL) {
tokr_err(t, "You can't defer something at global scope.");
return false;
}
- s->kind = STMT_DEFER;
++t->token;
+ s->kind = STMT_DEFER;
+ Token *deferred_start = t->token;
s->defer = parser_malloc(p, sizeof *s->defer);
if (!parse_stmt(p, s->defer, was_a_statement))
return false;
+ if (!*was_a_statement) {
+ err_print(token_location(p->file, deferred_start), "Empty defer");
+ return false;
+ }
goto success;
+ }
default: break;
}
} else if (t->token->kind == TOKEN_DIRECT) {