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)
diff --git a/src/vim9expr.c b/src/vim9expr.c
index 95c6d7d..1034f64 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -357,7 +357,7 @@
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;