From 2aa3ba274c46f35c094c5e4523b5274cb9c2834d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 1 Mar 2021 20:01:28 +0100 Subject: [PATCH] :art: Improve @gack --- src/lib/object.c | 2 +- src/parse/check.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/object.c b/src/lib/object.c index d69f6695..afd7dffc 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -100,7 +100,7 @@ static ID_CHECK(opck_this) { ERR_O(exp_self(prim)->pos, _("keyword 'this' can be used only inside class definition...")) if(env->func && !vflag(env->func->value_ref, vflag_member)) ERR_O(exp_self(prim)->pos, _("keyword 'this' cannot be used inside static functions...")) - if(env->func && !strcmp(s_name(env->func->def->base->xid), "@gack")) + if(!exp_getuse(exp_self(prim)) && env->func && !strcmp(s_name(env->func->def->base->xid), "@gack")) return get_gack(env->class_def->info->parent); // get_gack ? return env->class_def; } diff --git a/src/parse/check.c b/src/parse/check.c index afc4f301..f652149b 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -289,6 +289,7 @@ ANN static Type prim_owned(const Env env, const Symbol *data) { const Value v = exp->d.prim.value; const m_str name = !GET_FLAG(v, static) ? "this" : v->from->owner_class->name; const Exp base = new_prim_id(env->gwion->mp, insert_symbol(name), prim_pos(data)); + exp_setuse(base, 1); exp->exp_type = ae_exp_dot; exp->d.exp_dot.base = base; exp->d.exp_dot.xid = *data; -- 2.43.0