From: Brendan Hansen Date: Thu, 3 Dec 2020 22:19:47 +0000 (-0600) Subject: small bugfix with recursive types X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=5ae62f69d496e309e11e807a60cc9b51d6a6198f;p=onyx.git small bugfix with recursive types --- diff --git a/onyx b/onyx index 7e0247a5..8ba60afe 100755 Binary files a/onyx and b/onyx differ diff --git a/src/onyxtypes.c b/src/onyxtypes.c index 298a066c..fa7e90f9 100644 --- a/src/onyxtypes.c +++ b/src/onyxtypes.c @@ -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);