aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-07-27 22:40:54 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2023-07-28 19:27:08 -0400
commitc80609dfecb57a3830583eeeb3e0fce5860d657b (patch)
treed98fff3fdcccd7ab72d38b8ea3c85647e845f61b /test
parent20f4216af5dc4d5cb547529a132d8682ce7b7536 (diff)
downloadzig-c80609dfecb57a3830583eeeb3e0fce5860d657b.tar.gz
zig-c80609dfecb57a3830583eeeb3e0fce5860d657b.zip
Sema: don't reorder tuple fields
This conflicts with anon structs which can be in-memory coercible but are never reordered. Closes #16242
Diffstat (limited to 'test')
-rw-r--r--test/behavior/tuple.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/behavior/tuple.zig b/test/behavior/tuple.zig
index e9d3fcd0aa..757db0aa16 100644
--- a/test/behavior/tuple.zig
+++ b/test/behavior/tuple.zig
@@ -453,3 +453,17 @@ test "tuple pointer is indexable" {
try expectEqual(@as(u32, 100), (&y)[0]);
try expectEqual(false, (&y)[1]);
}
+
+test "coerce anon tuple to tuple" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO
+
+ var x: u8 = 1;
+ var y: u16 = 2;
+ var t = .{ x, y };
+ var s: struct { u8, u16 } = t;
+ try expectEqual(x, s[0]);
+ try expectEqual(y, s[1]);
+}