| ... | ... | @@ -1208,6 +1208,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { |
| 1208 | 1208 | var sum_size = @as(usize, 0); |
| 1209 | 1209 | |
| 1210 | 1210 | inline for (info.fields) |field| { |
| 1211 | if (field.is_comptime) continue; |
| 1211 | 1212 | if (!hasUniqueRepresentation(field.type)) return false; |
| 1212 | 1213 | sum_size += @sizeOf(field.type); |
| 1213 | 1214 | } |
| ... | ... | @@ -1310,4 +1311,12 @@ test hasUniqueRepresentation { |
| 1310 | 1311 | |
| 1311 | 1312 | try testing.expect(hasUniqueRepresentation(@Vector(std.simd.suggestVectorLength(u8) orelse 1, u8))); |
| 1312 | 1313 | try testing.expect(@sizeOf(@Vector(3, u8)) == 3 or !hasUniqueRepresentation(@Vector(3, u8))); |
| 1314 | |
| 1315 | const StructWithComptimeFields = struct { |
| 1316 | comptime should_be_ignored: u64 = 42, |
| 1317 | comptime should_also_be_ignored: [*:0]const u8 = "hope you're having a good day :)", |
| 1318 | field: u32, |
| 1319 | }; |
| 1320 | |
| 1321 | try testing.expect(hasUniqueRepresentation(StructWithComptimeFields)); |
| 1313 | 1322 | } |