1
0
forked from aniani/vim

patch 9.0.1240: cannot access a private object member in a lambda

Problem:    Cannot access a private object member in a lambda defined inside
            the class.
Solution:   Go up the context stack to find the class. (closes #11866)
This commit is contained in:
Bram Moolenaar
2023-01-24 15:07:04 +00:00
parent b149d22796
commit 62a6923470
5 changed files with 35 additions and 1 deletions

View File

@@ -357,7 +357,7 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
ocmember_T *m = &cl->class_obj_members[i];
if (STRNCMP(name, m->ocm_name, len) == 0 && m->ocm_name[len] == NUL)
{
if (*name == '_' && cctx->ctx_ufunc->uf_class != cl)
if (*name == '_' && !inside_class(cctx, cl))
{
semsg(_(e_cannot_access_private_member_str), m->ocm_name);
return FAIL;