diff options
| author | gingerBill <bill@gingerbill.org> | 2024-04-11 15:41:01 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-04-11 15:41:01 +0100 |
| commit | f36fb6d1ef6ad1f4c5dc56b9b761e843195546b6 (patch) | |
| tree | 4656f6ad5d9e57c057d95b9f56894bdf2fa43d4c /src | |
| parent | 45d7a670ce689b5be046e023102871566cac9b7b (diff) | |
Add `nil` checks
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_stmt.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index fc3b9aa43..a6def5997 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -2355,14 +2355,14 @@ gb_internal void check_return_stmt(CheckerContext *ctx, Ast *node) { unsafe_return_error(o, "the address of a compound literal"); } else if (x->kind == Ast_IndexExpr) { Entity *f = entity_of_node(x->IndexExpr.expr); - if (is_type_array_like(f->type) || is_type_matrix(f->type)) { + if (f && (is_type_array_like(f->type) || is_type_matrix(f->type))) { if (is_entity_local_variable(f)) { unsafe_return_error(o, "the address of an indexed variable", f->type); } } } else if (x->kind == Ast_MatrixIndexExpr) { Entity *f = entity_of_node(x->MatrixIndexExpr.expr); - if (is_type_matrix(f->type) && is_entity_local_variable(f)) { + if (f && (is_type_matrix(f->type) && is_entity_local_variable(f))) { unsafe_return_error(o, "the address of an indexed variable", f->type); } } |