0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.2527: Vim9: lambda return type is not determined at script level

Problem:    Vim9: lambda return type is not determined at script level.
Solution:   Compile the lambda to get the return type. (closes #7843)
This commit is contained in:
Bram Moolenaar
2021-02-17 17:00:27 +01:00
parent 527ed38cfa
commit 064095012c
5 changed files with 21 additions and 4 deletions

View File

@@ -1108,6 +1108,8 @@ def Test_assign_lambda()
assert_equal(123, FuncRef_Func())
var FuncRef_Any: any = () => 123
assert_equal(123, FuncRef_Any())
var FuncRef_Number: func(): number = () => 321
assert_equal(321, FuncRef_Number())
END
CheckScriptSuccess(lines)
@@ -1115,8 +1117,7 @@ def Test_assign_lambda()
var Ref: func(number)
Ref = (j) => !j
END
CheckDefFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(any): bool')
CheckScriptFailure(['vim9script'] + lines, 'E1012: Type mismatch; expected func(number) but got func(any): any')
CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(any): bool')
enddef
def Test_heredoc()