AstFunction* polymorphic_proc_build_only_header_with_slns(AstPolyProc* pp, bh_arr(AstPolySolution) slns);
void add_overload_option(bh_arr(OverloadOption)* poverloads, u64 precedence, AstTyped* overload);
-AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* args, b32* should_yield);
+AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* args);
AstTyped* find_matching_overload_by_type(bh_arr(OverloadOption) overloads, Type* type);
void report_unable_to_match_overload(AstCall* call);
b32 calling_a_macro = 0;
if (callee->kind == Ast_Kind_Overloaded_Function) {
- b32 should_yield = 0;
AstTyped* new_callee = find_matching_overload_by_arguments(
((AstOverloadedFunction *) callee)->overloads,
- &call->args,
- &should_yield);
+ &call->args);
if (new_callee == NULL) {
- if (callee->entity->state > Entity_State_Check_Types && !should_yield) {
- report_unable_to_match_overload(call);
- return Check_Error;
+ report_unable_to_match_overload(call);
+ return Check_Error;
+ }
- } else {
- YIELD(call->token->pos, "Waiting for overloaded function option to pass type-checking.");
- }
+ if (new_callee == (AstTyped *) &node_that_signals_a_yield) {
+ YIELD(call->token->pos, "Waiting for overloaded function option to pass type-checking.");
}
callee = new_callee;
args.values[1] = (AstTyped *) make_argument(context.ast_alloc, binop->right);
if (third_argument != NULL) args.values[2] = (AstTyped *) make_argument(context.ast_alloc, third_argument);
- b32 should_yield = 0;
- AstTyped* overload = find_matching_overload_by_arguments(operator_overloads[binop->operation], &args, &should_yield);
- if (should_yield) return (AstCall *) &node_that_signals_a_yield;
- if (overload == NULL) return NULL;
+ AstTyped* overload = find_matching_overload_by_arguments(operator_overloads[binop->operation], &args);
+ if (overload == NULL || overload == (AstTyped *) &node_that_signals_a_yield) return (AstCall *) overload;
AstCall* implicit_call = onyx_ast_node_new(context.ast_alloc, sizeof(AstCall), Ast_Kind_Call);
implicit_call->token = binop->token;
}
solid->resolved_proc = polymorphic_proc_try_solidify(solid->poly_proc, solid->known_polyvars, solid->token);
- if (solid->resolved_proc == (AstFunction *) &node_that_signals_a_yield) {
+ if (solid->resolved_proc == (AstTyped *) &node_that_signals_a_yield) {
solid->resolved_proc = NULL;
return Symres_Yield_Macro;
}
}
}
-AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* param_args, b32* should_yield) {
+AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* param_args) {
Arguments args;
arguments_clone(&args, param_args);
arguments_ensure_length(&args, bh_arr_length(args.values) + bh_arr_length(args.named_values));
// NOTE: Overload is not something that is known to be overloadable.
if (overload == NULL) continue;
- if (overload == (AstFunction *) &node_that_signals_a_yield) {
- // If it was not possible to create the type for this procedure, tell the
- // caller that this should yield and try again later.
- if (should_yield) *should_yield = 1;
-
- return NULL;
- }
+ if (overload == (AstFunction *) &node_that_signals_a_yield) return (AstTyped *) overload;
if (overload->kind != Ast_Kind_Function) continue;
if (overload->type == NULL) {
// If it was not possible to create the type for this procedure, tell the
// caller that this should yield and try again later.
- if (should_yield) *should_yield = 1;
// return and not continue because if the overload that didn't have a type will
// work in the future, then it has to take precedence over the other options available.
- return NULL;
+ return (AstTyped *) &node_that_signals_a_yield;
}
assert(overload->type->kind == Type_Kind_Function);
}
if (tm == TYPE_MATCH_YIELD) {
- if (should_yield) *should_yield = 1;
- return NULL;
+ return (AstTyped *) &node_that_signals_a_yield;
}
}