From 2bfc72586a7eff37379d513ce205bcc82d9a8b17 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Tue, 9 Apr 2024 15:55:40 +0200 Subject: [PATCH] Fix issue with distinct void as a member #1147 --- src/compiler/compiler_internal.h | 4 ++++ test/test_suite/struct/struct_bad_member.c3 | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index d6849afa6..42f9f5dd7 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -2848,6 +2848,10 @@ static inline StorageType type_storage_type(Type *type) case TYPE_TYPEDEF: type = type->canonical; goto RETRY; + case TYPE_DISTINCT: + is_distinct = true; + type = type->decl->distinct->type; + goto RETRY; default: return STORAGE_NORMAL; } diff --git a/test/test_suite/struct/struct_bad_member.c3 b/test/test_suite/struct/struct_bad_member.c3 index fffaf25d7..49486d7ed 100644 --- a/test/test_suite/struct/struct_bad_member.c3 +++ b/test/test_suite/struct/struct_bad_member.c3 @@ -6,7 +6,14 @@ def Void = void; struct Foo2 { Void bar; // #error: Members cannot be of } + +distinct Void2 = void; +struct Foo3 { + Void2 bar; // #error: has unknown size +} + fn void main(String[] args) { Foo foo; Foo2 foo2; + Foo3 foo3; }