From 5faf859a561e63000184b592154c6503be024fb4 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 24 Mar 2021 22:34:55 +0000 Subject: Support `using` on intermediate soa field value from a for-in statement --- src/check_stmt.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/check_stmt.cpp') diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 46eb1d177..402324cdd 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -558,8 +558,11 @@ 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) { - // TODO(bill): Make it work for unions too Scope *found = scope_of_node(t->Struct.node); + if (found == nullptr) { + found = t->Struct.scope; + } + GB_ASSERT(found != nullptr); for_array(i, found->elements.entries) { Entity *f = found->elements.entries[i].value; if (f->kind == Entity_Variable) { -- cgit v1.2.3