| ... | ... | @@ -2177,7 +2177,7 @@ test "avoid unused field function body compile error" { |
| 2177 | 2177 | |
| 2178 | 2178 | test "pass a pointer to a comptime-only struct field to a function" { |
| 2179 | 2179 | const S = struct { |
| 2180 | | fn checkField(field_ptr: *const type) !void { |
| 2180 | fn checkField(comptime field_ptr: *const type) !void { |
| 2181 | 2181 | try expect(field_ptr.* == u42); |
| 2182 | 2182 | } |
| 2183 | 2183 | }; |
| ... | ... | @@ -2233,3 +2233,24 @@ test "overaligned extern struct fields" { |
| 2233 | 2233 | try expect(std.mem.isAligned(@intFromPtr(&e.c), @alignOf(u32))); |
| 2234 | 2234 | try expect(std.mem.isAligned(@intFromPtr(&e.d), @alignOf(B))); |
| 2235 | 2235 | } |
| 2236 | |
| 2237 | test "runtime-known slice of comptime-only struct" { |
| 2238 | const Mixed = struct { index: u32, T: type }; |
| 2239 | |
| 2240 | const static = struct { |
| 2241 | fn doTheTest(index_offset: usize, s: []const Mixed) !void { |
| 2242 | for (s, index_offset..) |*mixed, index| { |
| 2243 | try expect(mixed.index == index); |
| 2244 | } |
| 2245 | } |
| 2246 | }; |
| 2247 | |
| 2248 | try static.doTheTest(10, &.{ |
| 2249 | .{ .index = 10, .T = u8 }, |
| 2250 | .{ .index = 11, .T = noreturn }, |
| 2251 | .{ .index = 12, .T = *opaque {} }, |
| 2252 | .{ .index = 13, .T = undefined }, |
| 2253 | .{ .index = 14, .T = @TypeOf(undefined) }, |
| 2254 | .{ .index = 15, .T = Mixed }, |
| 2255 | }); |
| 2256 | } |