aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/basic.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-05-30 17:35:18 -0400
committerGitHub <noreply@github.com>2022-05-30 17:35:18 -0400
commitc84f5a5f91d31b20b2e187d84fc8a80a190a1212 (patch)
treef2c580bac4ad1a649b3decd370ddb6f12316337e /test/behavior/basic.zig
parentf846dc420fff629572caa1175bfa64e5fcffaeb5 (diff)
parent0e8307789a3de41759e68c7c04c130889e277991 (diff)
downloadzig-c84f5a5f91d31b20b2e187d84fc8a80a190a1212.tar.gz
zig-c84f5a5f91d31b20b2e187d84fc8a80a190a1212.zip
Merge pull request #11749 from Vexu/stage2
Stage2: improve AstGen for array init expressions
Diffstat (limited to 'test/behavior/basic.zig')
-rw-r--r--test/behavior/basic.zig35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig
index ac9e776c76..e887a1d4b6 100644
--- a/test/behavior/basic.zig
+++ b/test/behavior/basic.zig
@@ -942,3 +942,38 @@ test "comptime int in switch in catch is casted to correct inferred type" {
};
_ = b;
}
+
+test "vector initialized with array init syntax has proper type" {
+ comptime {
+ const actual = -@Vector(4, i32){ 1, 2, 3, 4 };
+ 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 },
+ };
+}