1
0
forked from aniani/vim

patch 8.2.4612: Vim9: cannot use a recursive call in a nested function

Problem:    Vim9: cannot use a recursive call in a nested function. (Sergey
            Vlasov)
Solution:   Define the funcref before compiling the function. (closes #9989)
This commit is contained in:
Bram Moolenaar
2022-03-23 11:29:15 +00:00
parent 81b573d7e5
commit a915fa0103
6 changed files with 52 additions and 21 deletions

View File

@@ -876,6 +876,25 @@ def Test_nested_function()
END
v9.CheckScriptSuccess(lines)
# nested function with recursive call
lines =<< trim END
vim9script
def MyFunc(): number
def Fib(n: number): number
if n < 2
return 1
endif
return Fib(n - 2) + Fib(n - 1)
enddef
return Fib(5)
enddef
assert_equal(8, MyFunc())
END
v9.CheckScriptSuccess(lines)
lines =<< trim END
vim9script
def Outer()