]> Nishi Git Mirror - gwion.git/commitdiff
:art: Improve did_you_mean_type
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Thu, 17 Sep 2020 00:05:36 +0000 (02:05 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Thu, 17 Sep 2020 00:05:36 +0000 (02:05 +0200)
src/lib/object_op.c
src/parse/did_you_mean.c

index b019aa9f7fb401d8ebada4a927639cf83814ddcc..3b15c4ee1683cf41f65e3d89d5acac2a678f031a 100644 (file)
@@ -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))
index 29ed8100c61202f94609614bfb35e0087ca3e6a5..b5d5e11934160b7a6f10ccd599cbdaf83b37a494 100644 (file)
@@ -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);
 }