From: Brendan Hansen Date: Thu, 3 Jun 2021 21:16:02 +0000 (-0500) Subject: small note and maybe a bugfix X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=86eeb145f75eec6ae5bb7091f4ef5159edb89a8c;p=onyx.git small note and maybe a bugfix --- diff --git a/bin/onyx b/bin/onyx index 201a94b1..95c26567 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/src/onyxchecker.c b/src/onyxchecker.c index 43a29c80..4307a085 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -1680,7 +1680,8 @@ CheckStatus check_struct(AstStructType* s_node) { fill_in_type((*smem)->initial_value); if ((*smem)->initial_value->type == NULL) return Check_Yield_Macro; - (*smem)->type = resolve_expression_type((*smem)->initial_value); + resolve_expression_type((*smem)->initial_value); + if ((*smem)->type == NULL) (*smem)->type = (*smem)->initial_value->type; if ((*smem)->type == NULL) { onyx_report_error((*smem)->initial_value->token->pos, "Unable to deduce type of initial value. This is probably a compiler bug."); diff --git a/src/onyxlex.c b/src/onyxlex.c index da72ce08..0437cb9d 100644 --- a/src/onyxlex.c +++ b/src/onyxlex.c @@ -71,7 +71,7 @@ static const char* token_type_names[] = { "true", "false", - "NOTE" + "NOTE", "TOKEN_TYPE_COUNT" }; diff --git a/src/onyxsymres.c b/src/onyxsymres.c index 97d4a153..73601791 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -993,6 +993,9 @@ static SymresStatus symres_struct_defaults(AstType* t) { if ((*smem)->initial_value != NULL) { SYMRES(expression, &(*smem)->initial_value); + // CLEANUP: I hate that this is here. The type inference for a struct member should happen once the actual type is known. + // There seems to be a problem with setting it in the checker however, because whenever I disable this code, somehow + // the compiler gets to the code generation without all the types figured out??? if ((*smem)->type_node == NULL && (*smem)->initial_value->type_node != NULL) { (*smem)->type_node = (*smem)->initial_value->type_node; }