aboutsummaryrefslogtreecommitdiff
path: root/src/check_stmt.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-02-17 11:11:56 +0000
committerGitHub <noreply@github.com>2026-02-17 11:11:56 +0000
commita7ed7ccd0c392cfbb6cb2e486fc7c75b16791902 (patch)
tree8a325415e65ad09cf81547b957753b99d867aaf9 /src/check_stmt.cpp
parentbfe1f234ec763fc79359f7614ae4cccab88780e7 (diff)
parent58deab46a3e2423789f2af5e6ec7a4ef69ce810e (diff)
Merge pull request #6259 from odin-lang/bill/range-init
`for init; x in y {}` style loops (proof of concept)
Diffstat (limited to 'src/check_stmt.cpp')
-rw-r--r--src/check_stmt.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index 8f17e66c4..bfa68ca78 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -1705,11 +1705,17 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags)
TEMPORARY_ALLOCATOR_GUARD();
- u32 new_flags = mod_flags | Stmt_BreakAllowed | Stmt_ContinueAllowed;
check_open_scope(ctx, node);
check_label(ctx, rs->label, node);
+ Operand init = {};
+ if (rs->init != nullptr) {
+ check_stmt(ctx, rs->init, mod_flags);
+ }
+
+ u32 new_flags = mod_flags | Stmt_BreakAllowed | Stmt_ContinueAllowed;
+
auto vals = array_make<Type *>(temporary_allocator(), 0, 2);
auto entities = array_make<Entity *>(temporary_allocator(), 0, 2);
bool is_map = false;