diff options
| author | gingerBill <bill@gingerbill.org> | 2018-04-10 20:18:16 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-04-10 20:18:16 +0100 |
| commit | b83c3f265b72a5971e55b76ddf81cf33c68a2b57 (patch) | |
| tree | 3503e7b708695626a17f2581f433d94c50012b31 /src/parser.cpp | |
| parent | 30f5a3bb9358ded6a48e8d8ba6f5eb0b3743a807 (diff) | |
Fix #209 #assert bug
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index f94a66cad..b050433e7 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3748,7 +3748,7 @@ AstNode *parse_stmt(AstFile *f) { return s; } else if (tag == "assert") { AstNode *t = ast_basic_directive(f, hash_token, tag); - return parse_call_expr(f, t); + return ast_expr_stmt(f, parse_call_expr(f, t)); } if (tag == "include") { @@ -4077,11 +4077,14 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, Array<AstNod node->kind != AstNode_WhenStmt) { // NOTE(bill): Sanity check - if (node->kind == AstNode_CallExpr && - node->CallExpr.proc->kind == AstNode_BasicDirective && - node->CallExpr.proc->BasicDirective.name == "assert") { - // NOTE(bill): Okay! - continue; + if (node->kind == AstNode_ExprStmt) { + AstNode *expr = node->ExprStmt.expr; + if (expr->kind == AstNode_CallExpr && + expr->CallExpr.proc->kind == AstNode_BasicDirective && + expr->CallExpr.proc->BasicDirective.name == "assert") { + // NOTE(bill): Okay! + continue; + } } syntax_error(node, "Only declarations are allowed at file scope, got %.*s", LIT(ast_node_strings[node->kind])); |