1
0
forked from aniani/vim

patch 8.2.0323: Vim9: calling a function that is defined later is slow

Problem:    Vim9: calling a function that is defined later is slow.
Solution:   Once the function is found update the instruction so it can be
            called directly.
This commit is contained in:
Bram Moolenaar
2020-02-26 21:24:23 +01:00
parent b35efa5ed0
commit 7eeefd4a39
4 changed files with 72 additions and 12 deletions

View File

@@ -212,6 +212,19 @@ func DefinedLater(arg)
return a:arg
endfunc
def FuncWithForwardCall()
return DefinedEvenLater("yes")
enddef
def DefinedEvenLater(arg: string): string
return arg
enddef
def Test_error_in_nested_function()
" Error in called function requires unwinding the call stack.
assert_fails('call FuncWithForwardCall()', 'E1029')
enddef
def Test_return_type_wrong()
CheckScriptFailure(['def Func(): number', 'return "a"', 'enddef'], 'expected number but got string')
CheckScriptFailure(['def Func(): string', 'return 1', 'enddef'], 'expected string but got number')