From 790caa86d2286d0c9b426092893cff68136d65ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 3 Jun 2020 15:04:24 +0200 Subject: [PATCH] :art: Improve ptr --- src/lib/ptr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib/ptr.c b/src/lib/ptr.c index ec09d1fb..e2cc692a 100644 --- a/src/lib/ptr.c +++ b/src/lib/ptr.c @@ -54,9 +54,10 @@ static OP_CHECK(opck_ptr_cast) { const Exp_Cast* cast = (Exp_Cast*)data; if(!cast->td->types || !cast->td->types->td) ERR_N(exp_self(cast)->pos, "'Ptr' needs types to cast") - DECL_ON(const Type, t, = type_decl_resolve(env, cast->td)) - if(!GET_FLAG(t, check)) - CHECK_BN(traverse_class_def(env, t->e->def)) + DECL_ON(const Type, t, = known_type(env, cast->td)) // was type_decl_resolve + const Type _t = get_type(t); + if(_t->e->def && !GET_FLAG(_t, check)) + CHECK_BN(traverse_class_def(env, _t->e->def)) const Type to = known_type(env, cast->td->types->td); if(isa(cast->exp->info->type, to) > 0) return t; @@ -73,8 +74,9 @@ static OP_CHECK(opck_ptr_implicit) { ERR_N(e->pos, _("can't cast %s value to Ptr"), access); e->info->cast_to = imp->t; exp_setvar(e, 1); - if(!GET_FLAG(imp->t, check)) - CHECK_BN(traverse_class_def(env, imp->t->e->def)) + const Type t = get_type(imp->t); + if(!GET_FLAG(t, check)) + CHECK_BN(traverse_class_def(env, t->e->def)) return imp->t; } return NULL; -- 2.43.0