forked from aniani/vim
patch 9.0.2057: Vim9: no strict type checks for funcrefs varargs
Problem: Vim9: no strict type checks for funcrefs varargs
Solution: Perform strict type checking when declaring funcrefs
with vararg declaration, add tests
closes: #13397
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
This commit is contained in:
committed by
Christian Brabandt
parent
d3e277f279
commit
3ec6c1fe3b
@@ -1995,7 +1995,7 @@ def Test_varargs_mismatch()
|
||||
var res = Map((v) => str2nr(v))
|
||||
assert_equal(12, res)
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected func(...any): number but got func(any): number')
|
||||
v9.CheckScriptFailure(lines, 'E1180: Variable arguments type must be a list: any')
|
||||
enddef
|
||||
|
||||
def Test_using_var_as_arg()
|
||||
@@ -2764,7 +2764,7 @@ def Test_func_type_fails()
|
||||
v9.CheckDefFailure(['var Ref1: func()', 'Ref1 = g:FuncOneArgRetNumber'], 'E1012: Type mismatch; expected func() but got func(number): number')
|
||||
v9.CheckDefFailure(['var Ref1: func(bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(bool) but got func(bool, number)')
|
||||
v9.CheckDefFailure(['var Ref1: func(?bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(?bool) but got func(bool, number)')
|
||||
v9.CheckDefFailure(['var Ref1: func(...bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(...bool) but got func(bool, number)')
|
||||
v9.CheckDefFailure(['var Ref1: func(...bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1180: Variable arguments type must be a list: bool')
|
||||
|
||||
v9.CheckDefFailure(['var RefWrong: func(string ,number)'], 'E1068:')
|
||||
v9.CheckDefFailure(['var RefWrong: func(string,number)'], 'E1069:')
|
||||
|
||||
Reference in New Issue
Block a user