forked from aniani/vim
patch 8.2.2619: Vim9: no test for return type of lambda
Problem: Vim9: no test for return type of lambda. Solution: Add a test.
This commit is contained in:
@@ -752,11 +752,26 @@ def Test_call_lambda_args()
|
||||
CheckDefFailure(lines, 'E1167:')
|
||||
enddef
|
||||
|
||||
def FilterWithCond(x: string, Cond: func(string): bool): bool
|
||||
return Cond(x)
|
||||
enddef
|
||||
|
||||
def Test_lambda_return_type()
|
||||
var lines =<< trim END
|
||||
var Ref = (): => 123
|
||||
END
|
||||
CheckDefAndScriptFailure(lines, 'E1157:', 1)
|
||||
|
||||
# this works
|
||||
for x in ['foo', 'boo']
|
||||
echo FilterWithCond(x, (v) => v =~ '^b')
|
||||
endfor
|
||||
|
||||
# this fails
|
||||
lines =<< trim END
|
||||
echo FilterWithCond('foo', (v) => v .. '^b')
|
||||
END
|
||||
CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected func(string): bool but got func(any): string', 1)
|
||||
enddef
|
||||
|
||||
def Test_lambda_uses_assigned_var()
|
||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2619,
|
||||
/**/
|
||||
2618,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user