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;
// 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);
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.");