aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/eval.zig
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 /test/behavior/eval.zig
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 'test/behavior/eval.zig')
-rw-r--r--test/behavior/eval.zig22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig
index ecc10859cd..950a2b6c10 100644
--- a/test/behavior/eval.zig
+++ b/test/behavior/eval.zig
@@ -368,3 +368,25 @@ test "return 0 from function that has u0 return type" {
}
}
}
+
+test "statically initialized struct" {
+ st_init_str_foo.x += 1;
+ try expect(st_init_str_foo.x == 14);
+}
+const StInitStrFoo = struct {
+ x: i32,
+ y: bool,
+};
+var st_init_str_foo = StInitStrFoo{
+ .x = 13,
+ .y = true,
+};
+
+test "inline for with same type but different values" {
+ var res: usize = 0;
+ inline for ([_]type{ [2]u8, [1]u8, [2]u8 }) |T| {
+ var a: T = undefined;
+ res += a.len;
+ }
+ try expect(res == 5);
+}