summaryrefslogtreecommitdiff
path: root/src/testdir/test_vim9_func.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test_vim9_func.vim')
-rw-r--r--src/testdir/test_vim9_func.vim19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 40affb39c..7365fd8dc 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1224,6 +1224,25 @@ def Test_set_opfunc_to_lambda()
CheckScriptSuccess(lines)
enddef
+def Test_lambda_type_allocated()
+ # Check that unreferencing a partial using a lambda can use the variable type
+ # after the lambda has been freed and does not leak memory.
+ var lines =<< trim END
+ vim9script
+
+ func MyomniFunc1(val, findstart, base)
+ return a:findstart ? 0 : []
+ endfunc
+
+ var Lambda = (a, b) => MyomniFunc1(19, a, b)
+ &omnifunc = Lambda
+ Lambda = (a, b) => MyomniFunc1(20, a, b)
+ &omnifunc = string(Lambda)
+ Lambda = (a, b) => strlen(a)
+ END
+ CheckScriptSuccess(lines)
+enddef
+
" Default arg and varargs
def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string
var res = one .. ',' .. two