| ... | @@ -804,6 +804,52 @@ test "slice initialized through reference to anonymous array init provides resul | ... | @@ -804,6 +804,52 @@ test "slice initialized through reference to anonymous array init provides resul |
| 804 | try std.testing.expectEqualSlices(u16, &.{ 123, 456, 123, 456 }, foo); | 804 | try std.testing.expectEqualSlices(u16, &.{ 123, 456, 123, 456 }, foo); |
| 805 | } | 805 | } |
| 806 | | 806 | |
| | 807 | test "sentinel-terminated slice initialized through reference to anonymous array init provides result types" { |
| | 808 | var my_u32: u32 = 123; |
| | 809 | var my_u64: u64 = 456; |
| | 810 | _ = .{ &my_u32, &my_u64 }; |
| | 811 | const foo: [:999]const u16 = &.{ |
| | 812 | @intCast(my_u32), |
| | 813 | @intCast(my_u64), |
| | 814 | @truncate(my_u32), |
| | 815 | @truncate(my_u64), |
| | 816 | }; |
| | 817 | try std.testing.expectEqualSentinel(u16, 999, &.{ 123, 456, 123, 456 }, foo); |
| | 818 | } |
| | 819 | |
| | 820 | test "many-item pointer initialized through reference to anonymous array init provides result types" { |
| | 821 | var my_u32: u32 = 123; |
| | 822 | var my_u64: u64 = 456; |
| | 823 | _ = .{ &my_u32, &my_u64 }; |
| | 824 | const foo: [*]const u16 = &.{ |
| | 825 | @intCast(my_u32), |
| | 826 | @intCast(my_u64), |
| | 827 | @truncate(my_u32), |
| | 828 | @truncate(my_u64), |
| | 829 | }; |
| | 830 | try expectEqual(123, foo[0]); |
| | 831 | try expectEqual(456, foo[1]); |
| | 832 | try expectEqual(123, foo[2]); |
| | 833 | try expectEqual(456, foo[3]); |
| | 834 | } |
| | 835 | |
| | 836 | test "many-item sentinel-terminated pointer initialized through reference to anonymous array init provides result types" { |
| | 837 | var my_u32: u32 = 123; |
| | 838 | var my_u64: u64 = 456; |
| | 839 | _ = .{ &my_u32, &my_u64 }; |
| | 840 | const foo: [*:999]const u16 = &.{ |
| | 841 | @intCast(my_u32), |
| | 842 | @intCast(my_u64), |
| | 843 | @truncate(my_u32), |
| | 844 | @truncate(my_u64), |
| | 845 | }; |
| | 846 | try expectEqual(123, foo[0]); |
| | 847 | try expectEqual(456, foo[1]); |
| | 848 | try expectEqual(123, foo[2]); |
| | 849 | try expectEqual(456, foo[3]); |
| | 850 | try expectEqual(999, foo[4]); |
| | 851 | } |
| | 852 | |
| 807 | test "pointer to array initialized through reference to anonymous array init provides result types" { | 853 | test "pointer to array initialized through reference to anonymous array init provides result types" { |
| 808 | var my_u32: u32 = 123; | 854 | var my_u32: u32 = 123; |
| 809 | var my_u64: u64 = 456; | 855 | var my_u64: u64 = 456; |
| ... | @@ -817,6 +863,19 @@ test "pointer to array initialized through reference to anonymous array init pro | ... | @@ -817,6 +863,19 @@ test "pointer to array initialized through reference to anonymous array init pro |
| 817 | try std.testing.expectEqualSlices(u16, &.{ 123, 456, 123, 456 }, foo); | 863 | try std.testing.expectEqualSlices(u16, &.{ 123, 456, 123, 456 }, foo); |
| 818 | } | 864 | } |
| 819 | | 865 | |
| | 866 | test "pointer to sentinel-terminated array initialized through reference to anonymous array init provides result types" { |
| | 867 | var my_u32: u32 = 123; |
| | 868 | var my_u64: u64 = 456; |
| | 869 | _ = .{ &my_u32, &my_u64 }; |
| | 870 | const foo: *const [4:999]u16 = &.{ |
| | 871 | @intCast(my_u32), |
| | 872 | @intCast(my_u64), |
| | 873 | @truncate(my_u32), |
| | 874 | @truncate(my_u64), |
| | 875 | }; |
| | 876 | try std.testing.expectEqualSentinel(u16, 999, &.{ 123, 456, 123, 456 }, foo); |
| | 877 | } |
| | 878 | |
| 820 | test "tuple initialized through reference to anonymous array init provides result types" { | 879 | test "tuple initialized through reference to anonymous array init provides result types" { |
| 821 | const Tuple = struct { u64, *const u32 }; | 880 | const Tuple = struct { u64, *const u32 }; |
| 822 | const foo: *const Tuple = &.{ | 881 | const foo: *const Tuple = &.{ |