summaryrefslogtreecommitdiff
path: root/src/vim9class.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-01-24 15:07:04 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-24 15:07:04 +0000
commit62a6923470827acbf124df41134ae6df52f334e6 (patch)
tree52f1ea2c62400809c2a75075da2d33466a9fe62f /src/vim9class.c
parentb149d2279673aa89ab5e35958d05cc4bcc70f82a (diff)
downloadvim-git-9.0.1240.tar.gz
patch 9.0.1240: cannot access a private object member in a lambdav9.0.1240
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)
Diffstat (limited to 'src/vim9class.c')
-rw-r--r--src/vim9class.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/vim9class.c b/src/vim9class.c
index 0262e025d..484500576 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -1388,6 +1388,19 @@ class_member_index(char_u *name, size_t len, class_T **cl_ret, cctx_T *cctx)
}
/*
+ * 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.
*/
void