From 4252e007ebde0e06aa652e9f8aa240f8e2498aea Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sat, 19 Jun 2021 21:24:21 +0200 Subject: [PATCH] :bug: Fix check_exp_if --- src/parse/check.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/parse/check.c b/src/parse/check.c index e13cca4f..ab179976 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -951,14 +951,17 @@ ANN static Type _flow(const Env env, const Exp e, const m_bool b) { } #define check_flow(emit, b) _flow(emit, b, 1) -ANN static Type check_exp_if(const Env env, const Exp_If *exp_if) { - const Exp e = exp_if->if_exp ?: exp_if->cond; +ANN static Type check_exp_if(const Env env, Exp_If *const exp_if) { + if(!exp_if->if_exp) { + const Exp e = exp_if->if_exp = cpy_exp(env->gwion->mp, exp_if->cond); + scan1_exp(env, e); + scan2_exp(env, e); + } DECL_OO(const Type, cond, = check_flow(env, exp_if->cond)); - DECL_OO(const Type, if_exp, - = (exp_if->if_exp ? check_exp(env, exp_if->if_exp) : cond)); + DECL_OO(const Type, if_exp, = check_exp(env, exp_if->if_exp)); DECL_OO(const Type, else_exp, = check_exp(env, exp_if->else_exp)); - const uint meta = exp_getmeta(e) || exp_getmeta(exp_if->else_exp); + const uint meta = exp_getmeta(exp_if->if_exp) || exp_getmeta(exp_if->else_exp); exp_setmeta(exp_self(exp_if), meta); const Type ret = find_common_anc(if_exp, else_exp); if (!ret) -- 2.43.0