mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix #209 #assert bug
This commit is contained in:
+3
-1
@@ -1012,8 +1012,10 @@ Entity *check_ident(Checker *c, Operand *o, AstNode *n, Type *named_type, Type *
|
|||||||
|
|
||||||
|
|
||||||
if (e->type == nullptr) {
|
if (e->type == nullptr) {
|
||||||
|
if (e->state == EntityState_Unresolved) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
compiler_error("How did this happen? type: %s; identifier: %.*s\n", type_to_string(e->type), LIT(name));
|
compiler_error("How did this happen? type: %s; identifier: %.*s\n", type_to_string(e->type), LIT(name));
|
||||||
// return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e->flags |= EntityFlag_Used;
|
e->flags |= EntityFlag_Used;
|
||||||
|
|||||||
+9
-6
@@ -3748,7 +3748,7 @@ AstNode *parse_stmt(AstFile *f) {
|
|||||||
return s;
|
return s;
|
||||||
} else if (tag == "assert") {
|
} else if (tag == "assert") {
|
||||||
AstNode *t = ast_basic_directive(f, hash_token, tag);
|
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") {
|
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) {
|
node->kind != AstNode_WhenStmt) {
|
||||||
// NOTE(bill): Sanity check
|
// NOTE(bill): Sanity check
|
||||||
|
|
||||||
if (node->kind == AstNode_CallExpr &&
|
if (node->kind == AstNode_ExprStmt) {
|
||||||
node->CallExpr.proc->kind == AstNode_BasicDirective &&
|
AstNode *expr = node->ExprStmt.expr;
|
||||||
node->CallExpr.proc->BasicDirective.name == "assert") {
|
if (expr->kind == AstNode_CallExpr &&
|
||||||
// NOTE(bill): Okay!
|
expr->CallExpr.proc->kind == AstNode_BasicDirective &&
|
||||||
continue;
|
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]));
|
syntax_error(node, "Only declarations are allowed at file scope, got %.*s", LIT(ast_node_strings[node->kind]));
|
||||||
|
|||||||
Reference in New Issue
Block a user