0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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

@@ -1387,6 +1387,19 @@ class_member_index(char_u *name, size_t len, class_T **cl_ret, cctx_T *cctx)
return -1;
}
/*
* Return TRUE if current context "cctx_arg" is inside class "cl".
* Return FALSE if not.
*/
int
inside_class(cctx_T *cctx_arg, class_T *cl)
{
for (cctx_T *cctx = cctx_arg; cctx != NULL; cctx = cctx->ctx_outer)
if (cctx->ctx_ufunc != NULL && cctx->ctx_ufunc->uf_class == cl)
return TRUE;
return FALSE;
}
/*
* Make a copy of an object.
*/