diff options
| author | Ian Johnson <ian@ianjohnson.dev> | 2023-07-09 21:30:56 -0400 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-07-10 19:17:50 +0300 |
| commit | 3a30f0fa505e25c98772f9faffe5490b92773708 (patch) | |
| tree | cf01d2399b43aa5f4b6970422dcbd0683f15367f /test/behavior/struct.zig | |
| parent | 82a9d5d78d891b093c1755ecd5452b65619fdccf (diff) | |
| download | zig-3a30f0fa505e25c98772f9faffe5490b92773708.tar.gz zig-3a30f0fa505e25c98772f9faffe5490b92773708.zip | |
Sema: resolve field type layout for anon struct type info
Closes #16148
Diffstat (limited to 'test/behavior/struct.zig')
| -rw-r--r-- | test/behavior/struct.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index ab7b97ae94..72553e4058 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -1712,3 +1712,14 @@ test "extern struct field pointer has correct alignment" { try S.doTheTest(); try comptime S.doTheTest(); } + +test "packed struct field in anonymous struct" { + const T = packed struct { + f1: bool = false, + }; + + try std.testing.expect(countFields(.{ .t = T{} }) == 1); +} +fn countFields(v: anytype) usize { + return @typeInfo(@TypeOf(v)).Struct.fields.len; +} |
