diff options
| author | gingerBill <bill@gingerbill.org> | 2024-08-18 12:21:35 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-08-18 12:21:35 +0100 |
| commit | c4e0cbcd878f5984f559bdee1c6f02dc5a6e8ddc (patch) | |
| tree | 561f134b02b761174fd2af0d2b9d4d436813804a | |
| parent | f82bf6cd42c6a16705883af1e948b9ac85406899 (diff) | |
Fix #4005
| -rw-r--r-- | src/check_stmt.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index fbcabf3d2..cd1793a87 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1637,6 +1637,7 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) Ast *expr = unparen_expr(rs->expr); + bool is_range = false; bool is_possibly_addressable = true; isize max_val_count = 2; if (is_ast_range(expr)) { @@ -1645,6 +1646,7 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) Operand y = {}; is_possibly_addressable = false; + is_range = true; bool ok = check_range(ctx, expr, true, &x, &y, nullptr); if (!ok) { @@ -1889,7 +1891,9 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) } if (found == nullptr) { entity = alloc_entity_variable(ctx->scope, token, type, EntityState_Resolved); - entity->flags |= EntityFlag_ForValue; + if (!is_range) { + entity->flags |= EntityFlag_ForValue; + } entity->flags |= EntityFlag_Value; entity->identifier = name; entity->Variable.for_loop_parent_type = type_of_expr(expr); |