From: fennecdjay Date: Tue, 27 Feb 2024 20:47:37 +0000 (+0100) Subject: :art: improve xork X-Git-Tag: nightly~44 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=9b44186e1e3e24adc50c4f5ef6beffe7435331a3;p=gwion.git :art: improve xork --- diff --git a/src/lib/xork.c b/src/lib/xork.c index 57281235..d6f7bf69 100644 --- a/src/lib/xork.c +++ b/src/lib/xork.c @@ -59,7 +59,9 @@ static OP_CHECK(opck_spork) { } } const Func f = env->func; - struct Value_ value = { .type = env->gwion->type[et_function]}; + struct ValueFrom_ from; + valuefrom(env, &from); + struct Value_ value = { .type = env->gwion->type[et_function], .from = &from}; if(env->class_def) set_vflag(&value, vflag_member); struct Func_Base_ fbase = { .tag=MK_TAG(insert_symbol("in spork"), exp_self(unary)->loc), .values = &upvalues, .fbflag = fbflag_lambda}; diff --git a/src/parse/check.c b/src/parse/check.c index 240868c3..3c9e9d0b 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -698,18 +698,18 @@ ANN static void print_current_args(Exp* e) { gw_err("\n"); } -ANN2(1) +ANN2(1, 2) static void function_alternative(const Env env, const Type t, Exp* args, const loc_t loc) { - if (env->context && env->context->error) // needed for ufcs - return; + const bool is_closure = !isa(t, env->gwion->type[et_closure]); + Func f = is_closure + ? t->info->func + : closure_def(t)->base->func; + if(!f) return; gwerr_basic("Argument type mismatch", "call site", "valid alternatives:", env->name, loc, 0); - const bool is_closure = !isa(t, env->gwion->type[et_closure]); - Func up = is_closure - ? t->info->func : closure_def(t)->base->func; - do print_signature(up); - while ((up = up->next)); + do print_signature(f); + while ((f = f->next)); if (args) print_current_args(args); else @@ -1069,7 +1069,7 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { if(t) return t; } } - function_alternative(env, exp->func->type, exp->args, exp->func->loc); + function_alternative(env, t, exp->args, exp->func->loc); return NULL; }