aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorAndreas T Jonsson <mail@andreasjonsson.se>2024-05-16 13:48:44 +0200
committerAndreas T Jonsson <mail@andreasjonsson.se>2024-05-16 13:48:44 +0200
commita93bbf6f922cd59683c9ed1aeaf5bb9940c843c1 (patch)
treed30eb60984886812d2e36a32e501ed68f7453074 /src/check_type.cpp
parent5541f602335a74c357046a603119c6b49b63e25d (diff)
parentf9fd8f0c25bb0b239e5421c39217d2f8c449911f (diff)
Merge branch 'master' into netbsd-ci
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 4df0c5d19..c209a8e09 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -19,10 +19,12 @@ gb_internal void populate_using_array_index(CheckerContext *ctx, Ast *node, AstF
}
} else {
Token tok = make_token_ident(name);
- if (field->names.count > 0) {
- tok.pos = ast_token(field->names[0]).pos;
- } else {
- tok.pos = ast_token(field->type).pos;
+ if (field) {
+ if (field->names.count > 0) {
+ tok.pos = ast_token(field->names[0]).pos;
+ } else {
+ tok.pos = ast_token(field->type).pos;
+ }
}
Entity *f = alloc_entity_array_elem(nullptr, tok, t->Array.elem, idx);
add_entity(ctx, ctx->scope, nullptr, f);
@@ -191,9 +193,10 @@ gb_internal void check_struct_fields(CheckerContext *ctx, Ast *node, Slice<Entit
if (is_using && p->names.count > 0) {
Type *first_type = fields_array[fields_array.count-1]->type;
+ bool soa_ptr = is_type_soa_pointer(first_type);
Type *t = base_type(type_deref(first_type));
- if (!does_field_type_allow_using(t) &&
+ if ((soa_ptr || !does_field_type_allow_using(t)) &&
p->names.count >= 1 &&
p->names[0]->kind == Ast_Ident) {
Token name_token = p->names[0]->Ident.token;