diff options
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index b5e3d8c88..1a424240c 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -635,10 +635,7 @@ bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, b bool is_ptr = is_type_pointer(e->type); Type *t = base_type(type_deref(e->type)); if (t->kind == Type_Struct) { - Scope *found = scope_of_node(t->Struct.node); - if (found == nullptr) { - found = t->Struct.scope; - } + Scope *found = t->Struct.scope; GB_ASSERT(found != nullptr); for_array(i, found->elements.entries) { Entity *f = found->elements.entries[i].value; @@ -1399,9 +1396,9 @@ void check_block_stmt_for_errors(CheckerContext *ctx, Ast *body) { ast_node(bs, BlockStmt, body); // NOTE(bill, 2020-09-23): This logic is prevent common erros with block statements // e.g. if cond { x := 123; } // this is an error - if (body->scope != nullptr && body->scope->elements.entries.count > 0) { - if (body->scope->parent->node != nullptr) { - switch (body->scope->parent->node->kind) { + if (bs->scope != nullptr && bs->scope->elements.entries.count > 0) { + if (bs->scope->parent->node != nullptr) { + switch (bs->scope->parent->node->kind) { case Ast_IfStmt: case Ast_ForStmt: case Ast_RangeStmt: @@ -2339,7 +2336,8 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { } else if (is_type_struct(t) || is_type_raw_union(t)) { ERROR_BLOCK(); - Scope *scope = scope_of_node(t->Struct.node); + Scope *scope = t->Struct.scope; + GB_ASSERT(scope != nullptr); for_array(i, scope->elements.entries) { Entity *f = scope->elements.entries[i].value; if (f->kind == Entity_Variable) { |