summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/vim9.txt2
-rw-r--r--src/errors.h4
-rw-r--r--src/evalfunc.c5
-rw-r--r--src/filepath.c19
-rw-r--r--src/insexpand.c9
-rw-r--r--src/list.c10
-rw-r--r--src/match.c5
-rw-r--r--src/mbyte.c7
-rw-r--r--src/proto/typval.pro1
-rw-r--r--src/sign.c10
-rw-r--r--src/terminal.c6
-rw-r--r--src/testdir/test_functions.vim9
-rw-r--r--src/testdir/test_ins_complete.vim6
-rw-r--r--src/testdir/test_match.vim2
-rw-r--r--src/testdir/test_method.vim2
-rw-r--r--src/testdir/test_signs.vim4
-rw-r--r--src/testdir/test_terminal.vim2
-rw-r--r--src/testdir/test_textprop.vim2
-rw-r--r--src/testdir/test_utf8.vim2
-rw-r--r--src/textprop.c5
-rw-r--r--src/typval.c17
-rw-r--r--src/version.c2
22 files changed, 63 insertions, 68 deletions
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index b77b789a2..aba0f0051 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -1618,7 +1618,7 @@ type, it can not be used in Vim9 script.
*E1211* *E1217* *E1218* *E1219* *E1220* *E1221*
*E1222* *E1223* *E1224* *E1225* *E1226* *E1227*
*E1228* *E1238* *E1250* *E1251* *E1252* *E1253*
- *E1256* *E1297*
+ *E1256* *E1297* *E1298*
Types are checked for most builtin functions to make it easier to spot
mistakes.
diff --git a/src/errors.h b/src/errors.h
index 178443036..ee75d07e5 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -3318,5 +3318,9 @@ EXTERN char e_cannot_specify_both_type_and_types[]
EXTERN char e_can_only_use_left_padding_when_column_is_zero[]
INIT(= N_("E1296: Can only use left padding when column is zero"));
#endif
+#ifdef FEAT_EVAL
EXTERN char e_non_null_dict_required_for_argument_nr[]
INIT(= N_("E1297: Non-NULL Dictionary required for argument %d"));
+EXTERN char e_non_null_list_required_for_argument_nr[]
+ INIT(= N_("E1298: Non-NULL List required for argument %d"));
+#endif
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 9cbd41340..c7cf32297 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3235,11 +3235,8 @@ f_call(typval_T *argvars, typval_T *rettv)
|| check_for_opt_dict_arg(argvars, 2) == FAIL))
return;
- if (argvars[1].v_type != VAR_LIST)
- {
- emsg(_(e_list_required));
+ if (check_for_list_arg(argvars, 1) == FAIL)
return;
- }
if (argvars[1].vval.v_list == NULL)
return;
diff --git a/src/filepath.c b/src/filepath.c
index 70e0fd4e7..c61d71190 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -1603,19 +1603,20 @@ readdir_checkitem(void *context, void *item)
return checkitem_common(context, name, NULL);
}
+/*
+ * Process the keys in the Dict argument to the readdir() and readdirex()
+ * functions. Assumes the Dict argument is the 3rd argument.
+ */
static int
-readdirex_dict_arg(typval_T *tv, int *cmp)
+readdirex_dict_arg(typval_T *argvars, int *cmp)
{
char_u *compare;
- if (tv->v_type != VAR_DICT)
- {
- emsg(_(e_dictionary_required));
+ if (check_for_nonnull_dict_arg(argvars, 2) == FAIL)
return FAIL;
- }
- if (dict_has_key(tv->vval.v_dict, "sort"))
- compare = dict_get_string(tv->vval.v_dict, "sort", FALSE);
+ if (dict_has_key(argvars[2].vval.v_dict, "sort"))
+ compare = dict_get_string(argvars[2].vval.v_dict, "sort", FALSE);
else
{
semsg(_(e_dictionary_key_str_required), "sort");
@@ -1660,7 +1661,7 @@ f_readdir(typval_T *argvars, typval_T *rettv)
expr = &argvars[1];
if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN &&
- readdirex_dict_arg(&argvars[2], &sort) == FAIL)
+ readdirex_dict_arg(argvars, &sort) == FAIL)
return;
ret = readdir_core(&ga, path, FALSE, (void *)expr,
@@ -1713,7 +1714,7 @@ f_readdirex(typval_T *argvars, typval_T *rettv)
expr = &argvars[1];
if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN &&
- readdirex_dict_arg(&argvars[2], &sort) == FAIL)
+ readdirex_dict_arg(argvars, &sort) == FAIL)
return;
ret = readdir_core(&ga, path, TRUE, (void *)expr,
diff --git a/src/insexpand.c b/src/insexpand.c
index 1ff1c99b7..b91c23001 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -2930,9 +2930,7 @@ f_complete(typval_T *argvars, typval_T *rettv UNUSED)
if (!undo_allowed())
return;
- if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL)
- emsg(_(e_invalid_argument));
- else
+ if (check_for_nonnull_list_arg(argvars, 1) != FAIL)
{
startcol = (int)tv_get_number_chk(&argvars[0], NULL);
if (startcol > 0)
@@ -3143,11 +3141,8 @@ f_complete_info(typval_T *argvars, typval_T *rettv)
if (argvars[0].v_type != VAR_UNKNOWN)
{
- if (argvars[0].v_type != VAR_LIST)
- {
- emsg(_(e_list_required));
+ if (check_for_list_arg(argvars, 0) == FAIL)
return;
- }
what_list = argvars[0].vval.v_list;
}
get_complete_info(what_list, rettv->vval.v_dict);
diff --git a/src/list.c b/src/list.c
index 5e70f2111..c9697e051 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1519,11 +1519,8 @@ f_join(typval_T *argvars, typval_T *rettv)
|| check_for_opt_string_arg(argvars, 1) == FAIL))
return;
- if (argvars[0].v_type != VAR_LIST)
- {
- emsg(_(e_list_required));
+ if (check_for_list_arg(argvars, 0) == FAIL)
return;
- }
if (argvars[0].vval.v_list == NULL)
return;
@@ -1728,11 +1725,8 @@ f_list2str(typval_T *argvars, typval_T *rettv)
|| check_for_opt_bool_arg(argvars, 1) == FAIL))
return;
- if (argvars[0].v_type != VAR_LIST)
- {
- emsg(_(e_invalid_argument));
+ if (check_for_list_arg(argvars, 0) == FAIL)
return;
- }
l = argvars[0].vval.v_list;
if (l == NULL)
diff --git a/src/match.c b/src/match.c
index 335b06011..ebdaeabcf 100644
--- a/src/match.c
+++ b/src/match.c
@@ -1087,11 +1087,8 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|| check_for_opt_number_arg(argvars, 1) == FAIL))
return;
- if (argvars[0].v_type != VAR_LIST)
- {
- emsg(_(e_list_required));
+ if (check_for_list_arg(argvars, 0) == FAIL)
return;
- }
win = get_optional_window(argvars, 1);
if (win == NULL)
return;
diff --git a/src/mbyte.c b/src/mbyte.c
index 73065c739..54f7fa4fb 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -5535,14 +5535,9 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED)
size_t cw_table_size_save;
char *error = NULL;
- if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
+ if (check_for_nonnull_list_arg(argvars, 0) == FAIL)
return;
- if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL)
- {
- emsg(_(e_list_required));
- return;
- }
l = argvars[0].vval.v_list;
if (l->lv_len == 0)
{
diff --git a/src/proto/typval.pro b/src/proto/typval.pro
index 154b668b1..7d32a03d9 100644
--- a/src/proto/typval.pro
+++ b/src/proto/typval.pro
@@ -20,6 +20,7 @@ int check_for_bool_arg(typval_T *args, int idx);
int check_for_opt_bool_arg(typval_T *args, int idx);
int check_for_blob_arg(typval_T *args, int idx);
int check_for_list_arg(typval_T *args, int idx);
+int check_for_nonnull_list_arg(typval_T *args, int idx);
int check_for_opt_list_arg(typval_T *args, int idx);
int check_for_dict_arg(typval_T *args, int idx);
int check_for_nonnull_dict_arg(typval_T *args, int idx);
diff --git a/src/sign.c b/src/sign.c
index e0264ccb1..eaefd5f06 100644
--- a/src/sign.c
+++ b/src/sign.c
@@ -2660,11 +2660,8 @@ f_sign_placelist(typval_T *argvars, typval_T *rettv)
if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
return;
- if (argvars[0].v_type != VAR_LIST)
- {
- emsg(_(e_list_required));
+ if (check_for_list_arg(argvars, 0) == FAIL)
return;
- }
// Process the List of sign attributes
FOR_ALL_LIST_ITEMS(argvars[0].vval.v_list, li)
@@ -2888,11 +2885,8 @@ f_sign_unplacelist(typval_T *argvars, typval_T *rettv)
if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
return;
- if (argvars[0].v_type != VAR_LIST)
- {
- emsg(_(e_list_required));
+ if (check_for_list_arg(argvars, 0) == FAIL)
return;
- }
FOR_ALL_LIST_ITEMS(argvars[0].vval.v_list, li)
{
diff --git a/src/terminal.c b/src/terminal.c
index 0283267af..9600e0a68 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -6462,11 +6462,9 @@ f_term_setansicolors(typval_T *argvars, typval_T *rettv UNUSED)
if (term->tl_vterm == NULL)
return;
- if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL)
- {
- emsg(_(e_list_required));
+ if (check_for_nonnull_list_arg(argvars, 1) == FAIL)
return;
- }
+
if (argvars[1].vval.v_list->lv_first == &range_list_item
|| argvars[1].vval.v_list->lv_len != 16)
{
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 971be40dc..43eb265d6 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -2244,9 +2244,12 @@ func Test_readdir_sort()
exe "lang collate" collate
" 5) Errors
- call assert_fails('call readdir(dir, 1, 1)', 'E715:')
+ call assert_fails('call readdir(dir, 1, 1)', 'E1206:')
call assert_fails('call readdir(dir, 1, #{sorta: 1})')
+ call assert_fails('call readdir(dir, 1, test_null_dict())', 'E1297:')
+ call assert_fails('call readdirex(dir, 1, 1)', 'E1206:')
call assert_fails('call readdirex(dir, 1, #{sorta: 1})')
+ call assert_fails('call readdirex(dir, 1, test_null_dict())', 'E1297:')
" 6) ignore other values in dict
let files = readdir(dir, '1', #{sort: 'c'})
@@ -2285,7 +2288,7 @@ endfunc
func Test_call()
call assert_equal(3, call('len', [123]))
call assert_equal(3, 'len'->call([123]))
- call assert_fails("call call('len', 123)", 'E714:')
+ call assert_fails("call call('len', 123)", 'E1211:')
call assert_equal(0, call('', []))
call assert_equal(0, call('len', test_null_list()))
@@ -2580,7 +2583,7 @@ func Test_range()
" list2str()
call assert_equal('ABC', list2str(range(65, 67)))
- call assert_fails('let s = list2str(5)', 'E474:')
+ call assert_fails('let s = list2str(5)', 'E1211:')
" lock()
let thelist = range(5)
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 41998aa0e..cee6a329f 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -673,14 +673,14 @@ func Test_complete_func_error()
func ListColors()
call complete(col('.'), "blue")
endfunc
- call assert_fails('exe "normal i\<C-R>=ListColors()\<CR>"', 'E474:')
+ call assert_fails('exe "normal i\<C-R>=ListColors()\<CR>"', 'E1211:')
func ListMonths()
call complete(col('.'), test_null_list())
endfunc
- call assert_fails('exe "normal i\<C-R>=ListMonths()\<CR>"', 'E474:')
+ call assert_fails('exe "normal i\<C-R>=ListMonths()\<CR>"', 'E1298:')
delfunc ListColors
delfunc ListMonths
- call assert_fails('call complete_info({})', 'E714:')
+ call assert_fails('call complete_info({})', 'E1211:')
call assert_equal([], complete_info(['items']).items)
endfunc
diff --git a/src/testdir/test_match.vim b/src/testdir/test_match.vim
index 45f838975..f654761d6 100644
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -95,7 +95,7 @@ function Test_match()
call assert_equal(0, setmatches([]))
call assert_equal(0, setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}]))
call clearmatches()
- call assert_fails('call setmatches(0)', 'E714:')
+ call assert_fails('call setmatches(0)', 'E1211:')
call assert_fails('call setmatches([0])', 'E474:')
call assert_fails("call setmatches([{'wrong key': 'wrong value'}])", 'E474:')
call assert_equal(-1, setmatches([{'group' : 'Search', 'priority' : 10, 'id' : 5, 'pos1' : {}}]))
diff --git a/src/testdir/test_method.vim b/src/testdir/test_method.vim
index 22a930c5f..d31cce187 100644
--- a/src/testdir/test_method.vim
+++ b/src/testdir/test_method.vim
@@ -52,7 +52,7 @@ func Test_dict_method()
call assert_fails("let x = d->insert(0)", 'E899:')
call assert_true(d->has_key('two'))
call assert_equal([['one', 1], ['two', 2], ['three', 3]], d->items())
- call assert_fails("let x = d->join()", 'E714:')
+ call assert_fails("let x = d->join()", 'E1211:')
call assert_equal(['one', 'two', 'three'], d->keys())
call assert_equal(3, d->len())
call assert_equal(#{one: 2, two: 3, three: 4}, d->map('v:val + 1'))
diff --git a/src/testdir/test_signs.vim b/src/testdir/test_signs.vim
index e23d9ac59..e2387b28c 100644
--- a/src/testdir/test_signs.vim
+++ b/src/testdir/test_signs.vim
@@ -2010,7 +2010,7 @@ func Test_sign_funcs_multi()
" Invalid arguments
call assert_equal([], sign_placelist([]))
- call assert_fails('call sign_placelist({})', "E714:")
+ call assert_fails('call sign_placelist({})', "E1211:")
call assert_fails('call sign_placelist([[]])', "E715:")
call assert_fails('call sign_placelist(["abc"])', "E715:")
call assert_fails('call sign_placelist([100])', "E715:")
@@ -2021,7 +2021,7 @@ func Test_sign_funcs_multi()
" Invalid arguments
call assert_equal([], []->sign_unplacelist())
- call assert_fails('call sign_unplacelist({})', "E714:")
+ call assert_fails('call sign_unplacelist({})', "E1211:")
call assert_fails('call sign_unplacelist([[]])', "E715:")
call assert_fails('call sign_unplacelist(["abc"])', "E715:")
call assert_fails('call sign_unplacelist([100])', "E715:")
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index d325f1966..93cb74d2a 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -2065,7 +2065,7 @@ func Test_terminal_ansicolors_func()
let colors[4] = 'Invalid'
call assert_fails('call term_setansicolors(buf, colors)', 'E254:')
- call assert_fails('call term_setansicolors(buf, {})', 'E714:')
+ call assert_fails('call term_setansicolors(buf, {})', 'E1211:')
set tgc&
call StopShellInTerminal(buf)
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 34fa6c93f..03ae9c97e 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -381,7 +381,7 @@ func Test_prop_add_list()
call assert_fails('call prop_add_list(#{type: "one"}, [[2, 2, 2, 2], [3, 20, 3, 22]])', 'E964:')
call assert_fails('eval #{type: "one"}->prop_add_list([[2, 2, 2, 2], [3, 20, 3, 22]])', 'E964:')
call assert_fails('call prop_add_list(test_null_dict(), [[2, 2, 2]])', 'E965:')
- call assert_fails('call prop_add_list(#{type: "one"}, test_null_list())', 'E714:')
+ call assert_fails('call prop_add_list(#{type: "one"}, test_null_list())', 'E1298:')
call assert_fails('call prop_add_list(#{type: "one"}, [test_null_list()])', 'E714:')
call DeletePropTypes()
bw!
diff --git a/src/testdir/test_utf8.vim b/src/testdir/test_utf8.vim
index 862e73b9a..bb99cb3e6 100644
--- a/src/testdir/test_utf8.vim
+++ b/src/testdir/test_utf8.vim
@@ -168,7 +168,7 @@ func Test_setcellwidths()
call setcellwidths([])
- call assert_fails('call setcellwidths(1)', 'E714:')
+ call assert_fails('call setcellwidths(1)', 'E1211:')
call assert_fails('call setcellwidths([1, 2, 0])', 'E1109:')
diff --git a/src/textprop.c b/src/textprop.c
index de3344f89..5f5c6a2aa 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -348,11 +348,8 @@ f_prop_add_list(typval_T *argvars, typval_T *rettv UNUSED)
|| check_for_list_arg(argvars, 1) == FAIL)
return;
- if (argvars[1].vval.v_list == NULL)
- {
- emsg(_(e_list_required));
+ if (check_for_nonnull_list_arg(argvars, 1) == FAIL)
return;
- }
dict = argvars[0].vval.v_dict;
if (dict == NULL || !dict_has_key(dict, "type"))
diff --git a/src/typval.c b/src/typval.c
index 101f48f34..12a741ec2 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -509,6 +509,23 @@ check_for_list_arg(typval_T *args, int idx)
}
/*
+ * Give an error and return FAIL unless "args[idx]" is a non-NULL list.
+ */
+ int
+check_for_nonnull_list_arg(typval_T *args, int idx)
+{
+ if (check_for_list_arg(args, idx) == FAIL)
+ return FAIL;
+
+ if (args[idx].vval.v_list == NULL)
+ {
+ semsg(_(e_non_null_list_required_for_argument_nr), idx + 1);
+ return FAIL;
+ }
+ return OK;
+}
+
+/*
* Check for an optional list argument at 'idx'
*/
int
diff --git a/src/version.c b/src/version.c
index dc45669b3..0e4634798 100644
--- a/src/version.c
+++ b/src/version.c
@@ -708,6 +708,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 345,
+/**/
344,
/**/
343,