diff --git a/src/Sema.zig b/src/Sema.zig index 4a4823df2d..4936d52238 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -33491,7 +33491,9 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { return sema.failWithOwnedErrorMsg(msg); } - if (struct_obj.layout == .Auto and mod.backendSupportsFeature(.field_reordering)) { + if (struct_obj.layout == .Auto and !struct_obj.is_tuple and + mod.backendSupportsFeature(.field_reordering)) + { const optimized_order = try mod.tmp_hack_arena.allocator().alloc(u32, struct_obj.fields.count()); for (struct_obj.fields.values(), 0..) |field, i| { 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]); +}