Fix using bug

This commit is contained in:
gingerBill
2023-08-07 15:18:45 +01:00
parent 0230b88078
commit b782fca75b
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -1983,7 +1983,7 @@ gb_internal void check_value_decl_stmt(CheckerContext *ctx, Ast *node, u32 mod_f
for (auto const &entry : scope->elements) { for (auto const &entry : scope->elements) {
Entity *f = entry.value; Entity *f = entry.value;
if (f->kind == Entity_Variable) { if (f->kind == Entity_Variable) {
Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, nullptr); Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, e->identifier);
uvar->flags |= (e->flags & EntityFlag_Value); uvar->flags |= (e->flags & EntityFlag_Value);
Entity *prev = scope_insert(ctx->scope, uvar); Entity *prev = scope_insert(ctx->scope, uvar);
if (prev != nullptr) { if (prev != nullptr) {
+1
View File
@@ -347,6 +347,7 @@ gb_internal Entity *alloc_entity_using_variable(Entity *parent, Token token, Typ
entity->using_parent = parent; entity->using_parent = parent;
entity->parent_proc_decl = parent->parent_proc_decl; entity->parent_proc_decl = parent->parent_proc_decl;
entity->using_expr = using_expr; entity->using_expr = using_expr;
GB_ASSERT(using_expr != nullptr);
entity->flags |= EntityFlag_Using; entity->flags |= EntityFlag_Using;
entity->flags |= EntityFlag_Used; entity->flags |= EntityFlag_Used;
entity->state = EntityState_Resolved; entity->state = EntityState_Resolved;