1
0
forked from aniani/vim

patch 9.0.1887: Vim9: class members are accessible via object

Problem:  Vim9: class members are accessible via object
Solution: Disable class member variable access using an object

Class methods can be accessed only using the class name and cannot be
accessed using an object. To be consistent with this, do the same for
class member variables also. They can be accessed only using the class
name and not using an object.

closes: #13057

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
Yegappan Lakshmanan
2023-09-09 11:33:29 +02:00
committed by Christian Brabandt
parent ee17b6f70d
commit 23c92d93c1
4 changed files with 65 additions and 78 deletions

View File

@@ -413,24 +413,6 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
}
}
for (int i = 0; i < cl->class_class_member_count; ++i)
{
ocmember_T *m = &cl->class_class_members[i];
if (STRNCMP(name, m->ocm_name, len) == 0 && m->ocm_name[len] == NUL)
{
if (*name == '_' && !inside_class(cctx, cl))
{
semsg(_(e_cannot_access_private_member_str), m->ocm_name);
return FAIL;
}
*arg = name_end;
if (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))
return generate_GET_ITF_MEMBER(cctx, cl, i, m->ocm_type,
TRUE);
return generate_GET_OBJ_MEMBER(cctx, i, m->ocm_type, TRUE);
}
}
// Could be a function reference: "obj.Func".
for (int i = 0; i < cl->class_obj_method_count; ++i)
{