disallow resume and suspend in noasync scopes

This commit is contained in:
Vexu
2020-03-09 15:51:51 +02:00
parent 3618256c97
commit 03c1431f9c
4 changed files with 43 additions and 27 deletions

View File

@@ -876,6 +876,7 @@ static AstNode *ast_parse_container_field(ParseContext *pc) {
// Statement
// <- KEYWORD_comptime? VarDecl
// / KEYWORD_comptime BlockExprStatement
// / KEYWORD_noasync BlockExprStatement
// / KEYWORD_suspend (SEMICOLON / BlockExprStatement)
// / KEYWORD_defer BlockExprStatement
// / KEYWORD_errdefer BlockExprStatement
@@ -899,6 +900,14 @@ static AstNode *ast_parse_statement(ParseContext *pc) {
return res;
}
Token *noasync = eat_token_if(pc, TokenIdKeywordNoAsync);
if (noasync != nullptr) {
AstNode *statement = ast_expect(pc, ast_parse_block_expr_statement);
AstNode *res = ast_create_node(pc, NodeTypeNoAsync, noasync);
res->data.noasync_expr.expr = statement;
return res;
}
Token *suspend = eat_token_if(pc, TokenIdKeywordSuspend);
if (suspend != nullptr) {
AstNode *statement = nullptr;