patch 8.2.0528: Vim9: function arguments insufficiently tested
Problem: Vim9: function arguments insufficiently tested.
Solution: Check types. Add more tests. Fix function with varargs only.
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index fb2180f..558f23c 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -130,6 +130,19 @@
assert_equal('one,two,three', MyDefVarargs('one', 'two', 'three'))
enddef
+" Only varargs
+def MyVarargsOnly(...args: list<string>): string
+ return join(args, ',')
+enddef
+
+def Test_call_varargs_only()
+ assert_equal('', MyVarargsOnly())
+ assert_equal('one', MyVarargsOnly('one'))
+ assert_equal('one,two', MyVarargsOnly('one', 'two'))
+ call CheckDefFailure(['MyVarargsOnly(1)'], 'E1013: argument 1: type mismatch, expected string but got number')
+ call CheckDefFailure(['MyVarargsOnly("one", 2)'], 'E1013: argument 2: type mismatch, expected string but got number')
+enddef
+
def Test_using_var_as_arg()
call writefile(['def Func(x: number)', 'let x = 234', 'enddef'], 'Xdef')
call assert_fails('so Xdef', 'E1006:')