diff src/testdir/test_vim9_func.vim @ 25630:c26eb08a0df2 v8.2.3351

patch 8.2.3351: Vim9: using a function by name may delete it Commit: https://github.com/vim/vim/commit/b033ee2ddfa8513b57111a56d6af9e45c41f7d1e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 15 16:08:36 2021 +0200 patch 8.2.3351: Vim9: using a function by name may delete it Problem: Vim9: using a function by name may delete it. (Naohiro Ono) Solution: Increment the reference count when using a function by name. (closes #8760)
author Bram Moolenaar <Bram@vim.org>
date Sun, 15 Aug 2021 16:15:03 +0200
parents f8bcd21e6e24
children c204815f3058
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -3089,6 +3089,23 @@ def Test_closing_brace_at_start_of_line(
   call CheckDefAndScriptSuccess(lines)
 enddef
 
+func CreateMydict()
+  let g:mydict = {}
+  func g:mydict.afunc()
+    let g:result = self.key
+  endfunc
+endfunc
+
+def Test_numbered_function_reference()
+  CreateMydict()
+  var output = execute('legacy func g:mydict.afunc')
+  var funcName = 'g:' .. substitute(output, '.*function \(\d\+\).*', '\1', '')
+  execute 'function(' .. funcName .. ', [], {key: 42})()'
+  # check that the function still exists
+  assert_equal(output, execute('legacy func g:mydict.afunc'))
+  unlet g:mydict
+enddef
+
 if has('python3')
   def Test_python3_heredoc()
     py3 << trim EOF