forked from aniani/vim
patch 8.2.2306: Vim9: when using function reference type is not checked
Problem: Vim9: when using function reference type is not checked.
Solution: When using a function reference lookup the type and check the
argument types. (issue #7629)
This commit is contained in:
@@ -579,6 +579,22 @@ def Test_call_funcref_wrong_args()
|
||||
|
||||
CheckScriptFailure(head + ["funcMap['func']('str', 123)"] + tail, 'E119:')
|
||||
CheckScriptFailure(head + ["funcMap['func']('str', 123, [1], 4)"] + tail, 'E118:')
|
||||
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
var Ref: func(number): any
|
||||
Ref = (j) => !j
|
||||
echo Ref(false)
|
||||
END
|
||||
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4)
|
||||
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
var Ref: func(number): any
|
||||
Ref = (j) => !j
|
||||
call Ref(false)
|
||||
END
|
||||
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4)
|
||||
enddef
|
||||
|
||||
def Test_call_lambda_args()
|
||||
|
||||
Reference in New Issue
Block a user