From a7ea59b0dcb0ebd0b36ad351cd8a9484c1097c4a Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Mon, 7 Oct 2019 21:32:27 +0200 Subject: [PATCH] :art: Improve similar op --- src/parse/scan0.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 0c85850f..2f5e096a 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -113,10 +113,16 @@ static OP_CHECK(opck_implicit_similar) { return bin->rhs->type; } +static OP_CHECK(opck_cast_similar) { + const Exp_Cast *cast = (Exp_Cast*)data; + return exp_self(cast)->type; +} + ANN static void scan0_implicit_similar(const Env env, const Type lhs, const Type rhs) { struct Op_Import opi = { .op=insert_symbol("@implicit"), .lhs=lhs, .rhs=rhs, .ck=opck_implicit_similar }; add_op(env->gwion, &opi); - opi.op=insert_symbol("@cast"); + opi.op=insert_symbol("$"); + opi.ck = opck_cast_similar; add_op(env->gwion, &opi); } @@ -196,7 +202,7 @@ ANN m_bool scan0_enum_def(const Env env, const Enum_Def edef) { add_type(env, nspc, t); mk_class(env, t); } - scan0_implicit_similar(env, env->gwion->type[et_int], t); + scan0_implicit_similar(env, t, env->gwion->type[et_int]); return GW_OK; } -- 2.43.0