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/vim9class.c b/src/vim9class.c
index 0262e02..4845005 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -1388,6 +1388,19 @@
}
/*
+ * 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