diff options
| author | gingerBill <bill@gingerbill.org> | 2024-05-13 14:44:53 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-05-13 14:44:53 +0100 |
| commit | 8fa20fb875849774942117af3a23cb676a3fd8d7 (patch) | |
| tree | 09bdda6a6d665113f92d35328298edf4fc62f224 /src/check_type.cpp | |
| parent | 1b593fc1cabb5dba048ef78439b2f6c42ce00be4 (diff) | |
Extra check for `field` being `nullptr`
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
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); |