From 62a6923470827acbf124df41134ae6df52f334e6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 24 Jan 2023 15:07:04 +0000 Subject: 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) --- src/vim9expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/vim9expr.c') diff --git a/src/vim9expr.c b/src/vim9expr.c index 95c6d7db0..1034f64b0 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -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; -- cgit v1.2.1