aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/basic.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-05-28 22:04:52 +0300
committerVeikka Tuominen <git@vexu.eu>2022-05-29 13:19:03 +0300
commit0e8307789a3de41759e68c7c04c130889e277991 (patch)
tree68d53b0b5669c002f26937d8f38244aed18c8ec2 /test/behavior/basic.zig
parentc7b778992ec539e237d8afa7c105dcbad7ee280c (diff)
downloadzig-0e8307789a3de41759e68c7c04c130889e277991.tar.gz
zig-0e8307789a3de41759e68c7c04c130889e277991.zip
AstGen: add tuple aware elem_type_index
Diffstat (limited to 'test/behavior/basic.zig')
-rw-r--r--test/behavior/basic.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig
index 11ecf089c5..e887a1d4b6 100644
--- a/test/behavior/basic.zig
+++ b/test/behavior/basic.zig
@@ -949,3 +949,31 @@ test "vector initialized with array init syntax has proper type" {
try std.testing.expectEqual(@Vector(4, i32){ -1, -2, -3, -4 }, actual);
}
}
+
+test "weird array and tuple initializations" {
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const E = enum { a, b };
+ const S = struct { e: E };
+ var a = false;
+ const b = S{ .e = .a };
+
+ _ = &[_]S{
+ if (a) .{ .e = .a } else .{ .e = .b },
+ };
+
+ if (true) return error.SkipZigTest;
+
+ const S2 = @TypeOf(.{ false, b });
+ _ = &S2{
+ true,
+ if (a) .{ .e = .a } else .{ .e = .b },
+ };
+ const S3 = @TypeOf(.{ .a = false, .b = b });
+ _ = &S3{
+ .a = true,
+ .b = if (a) .{ .e = .a } else .{ .e = .b },
+ };
+}