From 7905f0533f3fbbffec262a97b083d6aae450e46b Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 13 May 2024 12:01:16 +0100 Subject: Fix #3582 by disallowing it --- src/check_type.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/check_type.cpp') diff --git a/src/check_type.cpp b/src/check_type.cpp index 4df0c5d19..8d3c28f06 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -191,9 +191,10 @@ gb_internal void check_struct_fields(CheckerContext *ctx, Ast *node, Slicenames.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; -- cgit v1.2.3 From 8fa20fb875849774942117af3a23cb676a3fd8d7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 13 May 2024 14:44:53 +0100 Subject: Extra check for `field` being `nullptr` --- src/check_type.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/check_type.cpp') diff --git a/src/check_type.cpp b/src/check_type.cpp index 8d3c28f06..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); -- cgit v1.2.3