patch 8.2.2614: Vim9: function is deleted while executing
Problem: Vim9: function is deleted while executing.
Solution: increment the call count, when more than zero do not delete the
function but mark it as dead. (closes #7977)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index c476acf..418435b 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1561,6 +1561,35 @@
delete('Xreload.vim')
enddef
+" Define CallFunc so that the test can be compiled
+command CallFunc echo 'nop'
+
+def Test_script_reload_from_function()
+ var lines =<< trim END
+ vim9script
+
+ if exists('g:loaded')
+ finish
+ endif
+ g:loaded = 1
+ delcommand CallFunc
+ command CallFunc Func()
+ def Func()
+ so /tmp/test.vim
+ g:didTheFunc = 1
+ enddef
+ END
+ writefile(lines, 'XreloadFunc.vim')
+ source XreloadFunc.vim
+ CallFunc
+ assert_equal(1, g:didTheFunc)
+
+ delete('XreloadFunc.vim')
+ delcommand CallFunc
+ unlet g:loaded
+ unlet g:didTheFunc
+enddef
+
def Test_script_var_shadows_function()
var lines =<< trim END
vim9script