From: Jérémie Astor Date: Fri, 29 Nov 2019 10:21:07 +0000 (+0100) Subject: :bug: Fix auto assignment X-Git-Tag: nightly~2072 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=9ead2ad742bced99a13317740c868969914d6f29;p=gwion.git :bug: Fix auto assignment --- diff --git a/src/parse/check.c b/src/parse/check.c index 943cce1d..5b6ee893 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -806,12 +806,16 @@ ANN Type check_exp_call1(const Env env, const Exp_Call *exp) { ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) { CHECK_OO(check_exp(env, bin->lhs)) - if(bin->rhs->exp_type == ae_exp_decl && bin->rhs->d.exp_decl.type == env->gwion->type[et_auto]) - bin->rhs->type = bin->rhs->d.exp_decl.type = bin->lhs->type; CHECK_OO(check_exp(env, bin->rhs)) + const Type rhs = + !(bin->rhs->exp_type == ae_exp_decl && bin->rhs->d.exp_decl.type == env->gwion->type[et_auto]) ? + bin->rhs->type : bin->lhs->type; struct Op_Import opi = { .op=bin->op, .lhs=bin->lhs->type, - .rhs=bin->rhs->type, .data=(uintptr_t)bin, .pos=exp_self(bin)->pos }; - return op_check(env, &opi); + .rhs=rhs, .data=(uintptr_t)bin, .pos=exp_self(bin)->pos }; + const Type ret = op_check(env, &opi); + if(ret && bin->rhs->exp_type == ae_exp_decl && bin->rhs->d.exp_decl.type == env->gwion->type[et_auto]) + bin->rhs->type = bin->rhs->d.exp_decl.type = rhs; + return ret; } ANN static Type check_exp_cast(const Env env, const Exp_Cast* cast) {