From 9ead2ad742bced99a13317740c868969914d6f29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 29 Nov 2019 11:21:07 +0100 Subject: [PATCH] :bug: Fix auto assignment --- src/parse/check.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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) { -- 2.43.0