From: Jérémie Astor Date: Thu, 17 Sep 2020 00:05:36 +0000 (+0200) Subject: :art: Improve did_you_mean_type X-Git-Tag: nightly~1278 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=97e23a3595ab2ad912ed45fc168a20510d0adb00;p=gwion.git :art: Improve did_you_mean_type --- diff --git a/src/lib/object_op.c b/src/lib/object_op.c index b019aa9f..3b15c4ee 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -200,11 +200,11 @@ OP_CHECK(opck_object_dot) { const m_bool base_static = is_class(env->gwion, member->t_base); const Type the_base = base_static ? member->t_base->e->d.base_type : member->t_base; if(!the_base->nspc) - ERR_O(member->base->pos, + ERR_N(member->base->pos, _("type '%s' does not have members - invalid use in dot expression of %s"), the_base->name, str) if(member->xid == insert_symbol(env->gwion->st, "this") && base_static) - ERR_O(exp_self(member)->pos, + ERR_N(exp_self(member)->pos, _("keyword 'this' must be associated with object instance...")) const Value value = find_value(the_base, member->xid); if(!value) { @@ -212,18 +212,18 @@ OP_CHECK(opck_object_dot) { _("class '%s' has no member '%s'"), the_base->name, str); if(member->t_base->nspc) did_you_mean_type(the_base, str); - return NULL; + return env->gwion->type[et_null]; } - CHECK_BO(not_from_owner_class(env, the_base, value, exp_self(member)->pos)) + CHECK_BN(not_from_owner_class(env, the_base, value, exp_self(member)->pos)) if(!env->class_def || isa(env->class_def, value->from->owner_class) < 0) { if(GET_FLAG(value, private)) - ERR_O(exp_self(member)->pos, + ERR_N(exp_self(member)->pos, _("can't access private '%s' outside of class..."), value->name) else if(GET_FLAG(value, protect)) exp_setprot(exp_self(member), 1); } if(base_static && GET_FLAG(value, member)) - ERR_O(exp_self(member)->pos, + ERR_N(exp_self(member)->pos, _("cannot access member '%s.%s' without object instance..."), the_base->name, str) if(GET_FLAG(value, const)) diff --git a/src/parse/did_you_mean.c b/src/parse/did_you_mean.c index 29ed8100..b5d5e119 100644 --- a/src/parse/did_you_mean.c +++ b/src/parse/did_you_mean.c @@ -36,7 +36,7 @@ ANN static void ressembles(const Vector v, const Nspc nspc, const char* name) { struct scope_iter iter = { nspc->info->value, 0, 0 }; Value value; while(scope_iter(&iter, &value) > 0) { - if(!strcmp(name, value->name)) + if(vector_find(v, (vtype)value->name) > 0 &&!strcmp(name, value->name)) continue; if(wagner_fisher(name, value->name)) vector_add(v, (vtype)value->name); @@ -68,6 +68,5 @@ ANN void did_you_mean_type(Type type, const char* name) { while((t = t->e->parent) && t->nspc); for(m_uint i = 0; i < vector_size(&v); ++i) gw_err(_(" (did you mean '%s'?)\n"), (m_str)vector_at(&v, i)); - did_you_mean_nspc(type->nspc, name); vector_release(&v); }