From: Brendan Hansen Date: Thu, 19 Aug 2021 20:08:39 +0000 (-0500) Subject: bugfix with use in parameters and yielding X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=29f6eaafc6324172041e27078dce97077ec60284;p=onyx.git bugfix with use in parameters and yielding --- diff --git a/bin/onyx b/bin/onyx index 828be457..61209641 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/include/onyxastnodes.h b/include/onyxastnodes.h index 877cbce0..a632a022 100644 --- a/include/onyxastnodes.h +++ b/include/onyxastnodes.h @@ -830,6 +830,7 @@ struct AstParam { AstTyped *default_value; VarArgKind vararg_kind; + b32 use_processed : 1; }; struct AstFunction { AstTyped_base; diff --git a/src/onyxclone.c b/src/onyxclone.c index 8b5e8531..12ad5373 100644 --- a/src/onyxclone.c +++ b/src/onyxclone.c @@ -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; diff --git a/src/onyxsymres.c b/src/onyxsymres.c index 0372ee89..c571d28a 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -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.");