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/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index 4aa9bb3..e854571 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -12544,6 +12544,35 @@
assert_equal('A.Foo B.Foo', b.Bar())
END
v9.CheckSourceSuccess(lines)
+
+ # Test for using super in a lambda function to invoke a base class method from
+ # the new() method.
+ lines =<< trim END
+ vim9script
+
+ def G(F: func): string
+ return F()
+ enddef
+
+ class Base
+ def F(): string
+ return 'Base.F()'
+ enddef
+ endclass
+
+ class Foo extends Base
+ var s: string = 'x'
+ def new()
+ this.s = G((): string => {
+ return super.F()
+ })
+ enddef
+ endclass
+
+ var f = Foo.new()
+ assert_equal('Base.F()', f.s)
+ END
+ v9.CheckSourceSuccess(lines)
enddef
" Test for using a list of objects