mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
Sema: resolve field type layout for anon struct type info
Closes #16148
This commit is contained in:
parent
82a9d5d78d
commit
3a30f0fa50
@ -17293,6 +17293,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
|
||||
} });
|
||||
};
|
||||
|
||||
try sema.resolveTypeLayout(field_ty.toType());
|
||||
|
||||
const is_comptime = field_val != .none;
|
||||
const opt_default_val = if (is_comptime) field_val.toValue() else null;
|
||||
const default_val_ptr = try sema.optRefValue(block, field_ty.toType(), opt_default_val);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user