| author | |
| committer | |
| log | 3a30f0fa505e25c98772f9faffe5490b92773708 |
| tree | cf01d2399b43aa5f4b6970422dcbd0683f15367f |
| parent | 82a9d5d78d891b093c1755ecd5452b65619fdccf |
Closes #161482 files changed, 13 insertions(+), 0 deletions(-)
src/Sema.zig+2| ... | @@ -17293,6 +17293,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17293,6 +17293,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17293 | } }); | 17293 | } }); |
| 17294 | }; | 17294 | }; |
| 17295 | 17295 | ||
| 17296 | try sema.resolveTypeLayout(field_ty.toType()); | ||
| 17297 | |||
| 17296 | const is_comptime = field_val != .none; | 17298 | const is_comptime = field_val != .none; |
| 17297 | const opt_default_val = if (is_comptime) field_val.toValue() else null; | 17299 | const opt_default_val = if (is_comptime) field_val.toValue() else null; |
| 17298 | const default_val_ptr = try sema.optRefValue(block, field_ty.toType(), opt_default_val); | 17300 | const default_val_ptr = try sema.optRefValue(block, field_ty.toType(), opt_default_val); |
test/behavior/struct.zig+11| ... | @@ -1712,3 +1712,14 @@ test "extern struct field pointer has correct alignment" { | ... | @@ -1712,3 +1712,14 @@ test "extern struct field pointer has correct alignment" { |
| 1712 | try S.doTheTest(); | 1712 | try S.doTheTest(); |
| 1713 | try comptime S.doTheTest(); | 1713 | try comptime S.doTheTest(); |
| 1714 | } | 1714 | } |
| 1715 | |||
| 1716 | test "packed struct field in anonymous struct" { | ||
| 1717 | const T = packed struct { | ||
| 1718 | f1: bool = false, | ||
| 1719 | }; | ||
| 1720 | |||
| 1721 | try std.testing.expect(countFields(.{ .t = T{} }) == 1); | ||
| 1722 | } | ||
| 1723 | fn countFields(v: anytype) usize { | ||
| 1724 | return @typeInfo(@TypeOf(v)).Struct.fields.len; | ||
| 1725 | } |