aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-20 15:11:27 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-10-20 15:34:10 -0700
commit4cb5fed10ba2233a3b19c33b56585eb73da8b001 (patch)
treeb0f52f720e66ed1ea5ef7af2b418ec0b822a15c6 /src
parent361217bda2b4ce397a2b49ab7613162d1abcab67 (diff)
downloadzig-4cb5fed10ba2233a3b19c33b56585eb73da8b001.tar.gz
zig-4cb5fed10ba2233a3b19c33b56585eb73da8b001.zip
AstGen: make the index variable of `inline for` a `alloc_comptime`
Before it was being emitted as an `alloc` which caused inline for loops to not work correctly.
Diffstat (limited to 'src')
-rw-r--r--src/AstGen.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index d1f65b75ba..a17bcc16bd 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -5735,7 +5735,8 @@ fn forExpr(
const len = try parent_gz.addUnNode(.indexable_ptr_len, array_ptr, for_full.ast.cond_expr);
const index_ptr = blk: {
- const index_ptr = try parent_gz.addUnNode(.alloc, .usize_type, node);
+ const alloc_tag: Zir.Inst.Tag = if (is_inline) .alloc_comptime else .alloc;
+ const index_ptr = try parent_gz.addUnNode(alloc_tag, .usize_type, node);
// initialize to zero
_ = try parent_gz.addBin(.store, index_ptr, .zero_usize);
break :blk index_ptr;