patch 9.1.1332: Vim9: segfault when using super within a lambda
Problem: Vim9: segfault when using super within a lambda
(lifepillar)
Solution: inherit the class from the current function
(Yegappan Lakshmanan)
fixes: #17166
closes: #17185
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/vim9expr.c b/src/vim9expr.c
index 40c5fcc..d169ed7 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -1647,6 +1647,11 @@
++ufunc->uf_refcount;
clear_tv(&rettv);
+ if (cctx->ctx_ufunc != NULL)
+ // This lambda might be defined in a class method. Inherit the class
+ // from the current function.
+ ufunc->uf_defclass = cctx->ctx_ufunc->uf_defclass;
+
// Compile it here to get the return type. The return type is optional,
// when it's missing use t_unknown. This is recognized in
// compile_return().