From fc66a973244c84d6c38aedc1ae749c4a3c7baf74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 15 May 2022 20:28:10 +0200 Subject: [PATCH] :bug: Fix uncurry --- src/lib/lib_func.c | 8 ++++---- src/parse/check.c | 2 +- src/parse/partial.c | 8 +++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lib/lib_func.c b/src/lib/lib_func.c index c6992f6d..5d5cf211 100644 --- a/src/lib/lib_func.c +++ b/src/lib/lib_func.c @@ -28,8 +28,8 @@ ANN static Exp uncurry(const Env env, const Exp_Binary *bin) { args->next = NULL; if(tmp) tmp = (tmp->next = cpy_exp(env->gwion->mp, args)); else base = (tmp = cpy_exp(env->gwion->mp, args)); - args->next = next; - } else { + args->next = next; + } else { if(!lhs) { free_exp(env->gwion->mp, base); return NULL; @@ -62,8 +62,8 @@ static OP_CHECK(opck_func_call) { if(!strncmp(bin->rhs->type->name, "partial:", 8)) { const Stmt stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code->d.stmt_code.stmt_list, struct Stmt_, 0); const Exp_Call *call = &stmt->d.stmt_exp.val->d.exp_call; - const Exp args = uncurry(env, bin); - if(args) return mk_call(env, exp_self(bin), call->func, args); + DECL_ON(const Exp, args, = uncurry(env, bin)); + return mk_call(env, exp_self(bin), call->func, args); } return mk_call(env, exp_self(bin), bin->rhs, bin->lhs); } diff --git a/src/parse/check.c b/src/parse/check.c index 978ba4c6..2366510d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -357,7 +357,7 @@ ANN static Type prim_id_non_res(const Env env, const Symbol *data) { const Value v = check_non_res_value(env, data); if (!v || !vflag(v, vflag_valid) || (v->from->ctx && v->from->ctx->error)) { const m_str name = s_name(*data); - if (!isalpha(*name) && *name != '_') { /* && *name != '@' ???*/ + if (!isalpha(*name) && *name != '_') { prim_self(data)->value = env->gwion->type[et_op]->info->value; return env->gwion->type[et_op]; } diff --git a/src/parse/partial.c b/src/parse/partial.c index 9979a787..039cbbf2 100644 --- a/src/parse/partial.c +++ b/src/parse/partial.c @@ -49,7 +49,11 @@ ANN static Exp partial_exp(const Env env, Exp e, const uint i) { if(is_hole(env, e) || is_typed_hole(env, e)) { char c[256]; sprintf(c, "@%u", i); - return new_prim_id(env->gwion->mp, insert_symbol(c), e->pos); + const Exp exp = new_prim_id(env->gwion->mp, insert_symbol(c), e->pos); + exp->type = e->type; + exp->d.prim.value = new_value(env, e->type, c, e->pos); + valid_value(env, insert_symbol(c), exp->d.prim.value); + return exp; } const Exp next = e->next; e->next = NULL; @@ -212,11 +216,13 @@ ANN Type partial_type(const Env env, Exp_Call *const call) { } ERR_O(call->func->pos, _("no match found for partial application")); } + nspc_push_value(env->gwion->mp, env->curr); Func_Base *const fbase = partial_base(env, f->def->base, call->args, call->func->pos); const Stmt code = partial_code(env, call->func, call->args); const Exp exp = exp_self(call); exp->d.exp_lambda.def = new_func_def(env->gwion->mp, fbase, code); exp->exp_type = ae_exp_lambda; CHECK_OO(traverse_func_def(env, exp->d.exp_lambda.def)); + nspc_pop_value(env->gwion->mp, env->curr); return exp->d.exp_lambda.def->base->func->value_ref->type; } -- 2.43.0