bugfix with use in parameters and yielding
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 19 Aug 2021 20:08:39 +0000 (15:08 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 19 Aug 2021 20:08:39 +0000 (15:08 -0500)
bin/onyx
include/onyxastnodes.h
src/onyxclone.c
src/onyxsymres.c

index 828be4578e1b587992cee64d2bc63c0f1e2f2a3e..61209641ef06439b7698939dd0dce9c6b7fb936a 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 877cbce0bb7774ea872afbdce8ff9fd3031ffdda..a632a0226ba3195fc18e1f88f19f096f1cdd4553 100644 (file)
@@ -830,6 +830,7 @@ struct AstParam {
     AstTyped *default_value;
 
     VarArgKind vararg_kind;
+    b32 use_processed : 1;
 };
 struct AstFunction {
     AstTyped_base;
index 8b5e85316a1e4d4e31d0a4d2644a054a7a93801a..12ad53739460d05a3ffcecd12cff6a9d570ae5ae 100644 (file)
@@ -384,7 +384,7 @@ AstNode* ast_clone(bh_allocator a, void* n) {
                        bh_arr_new(global_heap_allocator, df->params, bh_arr_length(sf->params));
 
                        bh_arr_each(AstParam, param, sf->params) {
-                               AstParam new_param;
+                               AstParam new_param = { 0 };
                                new_param.local = (AstLocal *) ast_clone(a, param->local);
                                new_param.default_value = (AstTyped *) ast_clone(a, param->default_value);
                 new_param.vararg_kind = param->vararg_kind;
index 0372ee89532cd19adf8d0d79c5563dbb03d4b97f..c571d28a0b7389e38b32cf263546156a7d1f5405 100644 (file)
@@ -890,7 +890,7 @@ SymresStatus symres_function(AstFunction* func) {
             // The 'use t : T' member requires completely knowing the type of T, to know which
             // members should be brought in. At the moment, that requires completely building the
             // type of Foo($T).
-            if (param->local->flags & Ast_Flag_Param_Use) {
+            if ((param->local->flags & Ast_Flag_Param_Use) != 0 && param->use_processed == 0) {
                 if (param->local->type_node != NULL && param->local->type == NULL) {
                     param->local->type = type_build_from_ast(context.ast_alloc, param->local->type_node);
 
@@ -914,6 +914,8 @@ SymresStatus symres_function(AstFunction* func) {
                         symbol_raw_introduce(curr_scope, value.name, param->local->token->pos, (AstNode *) fa);
                     bh_table_each_end;
 
+                    param->use_processed = 1;
+
                 } else if (param->local->type != NULL) {
                     onyx_report_error(param->local->token->pos, "Can only 'use' structures or pointers to structures.");