small bugfix with recursive types
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 3 Dec 2020 22:19:47 +0000 (16:19 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 3 Dec 2020 22:19:47 +0000 (16:19 -0600)
onyx
src/onyxtypes.c

diff --git a/onyx b/onyx
index 7e0247a5b6035c68b0fbe296bc0b2f6bacc5b906..8ba60afead625fdeda138ee71b390718422c18bc 100755 (executable)
Binary files a/onyx and b/onyx differ
index 298a066c9c95bf7460fb68786bbb2eb723a88e53..fa7e90f97b01dc4064be3a7b5218b0354f3bbae6 100644 (file)
@@ -2,6 +2,7 @@
 #include "onyxtypes.h"
 #include "onyxastnodes.h"
 #include "onyxutils.h"
+#include "onyxerrors.h"
 
 // NOTE: These have to be in the same order as Basic
 Type basic_types[] = {
@@ -340,6 +341,11 @@ Type* type_build_from_ast(bh_allocator alloc, AstType* type_node) {
                 (*member)->type = type_build_from_ast(alloc, (*member)->type_node);
 
                 mem_alignment = type_alignment_of((*member)->type);
+                if (mem_alignment <= 0) {
+                    onyx_report_error((*member)->token->pos, "Invalid member type: %s", type_get_name((*member)->type)); 
+                    return s_type;
+                }
+
                 if (mem_alignment > alignment) alignment = mem_alignment;
                 if (offset % mem_alignment != 0) {
                     offset += mem_alignment - (offset % mem_alignment);