From 398d2cab6988e20c59e7037ff7ef551540339abb Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 5 Oct 2025 17:52:33 -0400 Subject: Fix a bunch of issues with optional types --- src/types.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/types.c') diff --git a/src/types.c b/src/types.c index 900588f5..bf986c80 100644 --- a/src/types.c +++ b/src/types.c @@ -476,11 +476,9 @@ PUREFUNC size_t type_size(type_t *t) { default: errx(1, "Invalid integer bit size"); } case StructType: { - size_t size = unpadded_struct_size(nonnull); - size += sizeof(bool); // is_null flag - size_t align = type_align(nonnull); - if (align > 0 && (size % align) > 0) size = (size + align) - (size % align); - return size; + arg_t *fields = new (arg_t, .name = "value", .type = nonnull, + .next = new (arg_t, .name = "has_value", .type = Type(BoolType))); + return type_size(Type(StructType, .fields = fields)); } default: return type_size(nonnull); } -- cgit v1.2.3