]> Nishi Git Mirror - gwion.git/commitdiff
:art: Improve similar op
authorfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 7 Oct 2019 19:32:27 +0000 (21:32 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 7 Oct 2019 19:32:27 +0000 (21:32 +0200)
src/parse/scan0.c

index 0c85850f33612413704f921ea7fe3a27cbcf3dec..2f5e096aea2ac7cde6c48c028efd705406eebd28 100644 (file)
@@ -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;
 }