From c4e0cbcd878f5984f559bdee1c6f02dc5a6e8ddc Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 18 Aug 2024 12:21:35 +0100 Subject: [PATCH] Fix #4005 --- src/check_stmt.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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);