aboutsummaryrefslogtreecommitdiff
path: root/src/check_stmt.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-03-24 22:34:55 +0000
committergingerBill <bill@gingerbill.org>2021-03-24 22:34:55 +0000
commit5faf859a561e63000184b592154c6503be024fb4 (patch)
treee9f764e01d31bb5eb97727199cad99add478d0f2 /src/check_stmt.cpp
parent7028797d5398699c2edbfd0ab1d83272bcdcd1ce (diff)
Support `using` on intermediate soa field value from a for-in statement
Diffstat (limited to 'src/check_stmt.cpp')
-rw-r--r--src/check_stmt.cpp5
1 files changed, 4 insertions, 1 deletions
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) {