From 24aa48b7a265c24e18f0f978dfe0255e138e2b90 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 25 Jul 2020 16:33:02 +0200 Subject: patch 8.2.1291: Vim9: type of varargs items is not checked Problem: Vim9: type of varargs items is not checked. Solution: Check the list item types. (closes #6523) --- src/testdir/test_vim9_func.vim | 50 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'src/testdir/test_vim9_func.vim') diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index ef98583fe..49be8f97a 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -164,7 +164,55 @@ def Test_call_def_varargs() assert_equal('one,foo', MyDefVarargs('one')) assert_equal('one,two', MyDefVarargs('one', 'two')) assert_equal('one,two,three', MyDefVarargs('one', 'two', 'three')) - call CheckDefFailure(['MyDefVarargs("one", 22)'], 'E1013: argument 2: type mismatch, expected string but got number') + CheckDefFailure(['MyDefVarargs("one", 22)'], + 'E1013: argument 2: type mismatch, expected string but got number') + CheckDefFailure(['MyDefVarargs("one", "two", 123)'], + 'E1013: argument 3: type mismatch, expected string but got number') + + let lines =<< trim END + vim9script + def Func(...l: list) + echo l + enddef + Func('a', 'b', 'c') + END + CheckScriptSuccess(lines) + + lines =<< trim END + vim9script + def Func(...l: list) + echo l + enddef + Func() + END + CheckScriptSuccess(lines) + + lines =<< trim END + vim9script + def Func(...l: list) + echo l + enddef + Func(1, 2, 3) + END + CheckScriptFailure(lines, 'E1013:') + + lines =<< trim END + vim9script + def Func(...l: list) + echo l + enddef + Func('a', 9) + END + CheckScriptFailure(lines, 'E1013:') + + lines =<< trim END + vim9script + def Func(...l: list) + echo l + enddef + Func(1, 'a') + END + CheckScriptFailure(lines, 'E1013:') enddef let s:value = '' -- cgit v1.2.1