small note and maybe a bugfix
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 3 Jun 2021 21:16:02 +0000 (16:16 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 3 Jun 2021 21:16:02 +0000 (16:16 -0500)
bin/onyx
src/onyxchecker.c
src/onyxlex.c
src/onyxsymres.c

index 201a94b120d9f13b7f02ce27549187fb0ee85dc5..95c265679c6417987aa01d618439a42b38332d29 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 43a29c80950097ee28af630a0331bbb44d38961d..4307a08533d12ffc2a2d0e46487b4847f4f31c9f 100644 (file)
@@ -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.");
index da72ce080fcd3cb0ee53b958acf0655aa35538f7..0437cb9d20dc495b8f9342a85e21777b839cc756 100644 (file)
@@ -71,7 +71,7 @@ static const char* token_type_names[] = {
     "true",
     "false",
 
-    "NOTE"
+    "NOTE",
 
     "TOKEN_TYPE_COUNT"
 };
index 97d4a15399b9a0f340dd59ed1cd6e781f77b90eb..73601791826e2b54167f0ab35f989d8c96a79bb7 100644 (file)
@@ -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;
             }