mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-25 23:14:59 -07:00
Runtime assert
This commit is contained in:
+18
-3
@@ -203,6 +203,21 @@ Type *check_init_variable(Checker *c, Entity *e, Operand *operand, String contex
|
||||
if (operand->mode == Addressing_Invalid ||
|
||||
operand->type == t_invalid ||
|
||||
e->type == t_invalid) {
|
||||
|
||||
if (operand->mode == Addressing_Builtin) {
|
||||
gbString expr_str = expr_to_string(operand->expr);
|
||||
defer (gb_string_free(expr_str));
|
||||
|
||||
// TODO(bill): is this a good enough error message?
|
||||
error(&c->error_collector, ast_node_token(operand->expr),
|
||||
"Cannot assign builtin procedure `%s` in %.*s",
|
||||
expr_str,
|
||||
LIT(context_name));
|
||||
|
||||
operand->mode = Addressing_Invalid;
|
||||
}
|
||||
|
||||
|
||||
if (e->type == NULL)
|
||||
e->type = t_invalid;
|
||||
return NULL;
|
||||
@@ -530,7 +545,7 @@ void check_entity_decl(Checker *c, Entity *e, DeclInfo *d, Type *named_type, Cyc
|
||||
|
||||
|
||||
|
||||
void check_var_decl(Checker *c, AstNode *node) {
|
||||
void check_var_decl_node(Checker *c, AstNode *node) {
|
||||
ast_node(vd, VarDecl, node);
|
||||
isize entity_count = vd->name_count;
|
||||
isize entity_index = 0;
|
||||
@@ -1150,7 +1165,7 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
|
||||
if (vd->name_count > 1 && vd->type != NULL) {
|
||||
error(&c->error_collector, us->token, "`using` can only be applied to one variable of the same type");
|
||||
}
|
||||
check_var_decl(c, us->node);
|
||||
check_var_decl_node(c, us->node);
|
||||
|
||||
for (AstNode *item = vd->name_list; item != NULL; item = item->next) {
|
||||
ast_node(i, Ident, item);
|
||||
@@ -1191,7 +1206,7 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
|
||||
|
||||
|
||||
case_ast_node(vd, VarDecl, node);
|
||||
check_var_decl(c, node);
|
||||
check_var_decl_node(c, node);
|
||||
case_end;
|
||||
|
||||
case_ast_node(pd, ProcDecl, node);
|
||||
|
||||
Reference in New Issue
Block a user