@@ -1540,12 +1540,6 @@ list_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg)
15401540 int error = FALSE;
15411541 long idx ;
15421542
1543- if (in_vim9script ()
1544- && (check_for_list_arg (argvars , 0 ) == FAIL
1545- || check_for_number_arg (argvars , 1 ) == FAIL
1546- || check_for_opt_number_arg (argvars , 2 ) == FAIL ))
1547- return ;
1548-
15491543 if ((l = argvars [0 ].vval .v_list ) == NULL
15501544 || value_check_lock (l -> lv_lock , arg_errmsg , TRUE))
15511545 return ;
@@ -1806,6 +1800,12 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
18061800 long len ;
18071801 long i ;
18081802
1803+ if (in_vim9script ()
1804+ && (check_for_list_arg (argvars , 0 ) == FAIL
1805+ || (argvars [1 ].v_type != VAR_UNKNOWN
1806+ && check_for_opt_dict_arg (argvars , 2 ) == FAIL )))
1807+ return ;
1808+
18091809 // Pointer to current info struct used in compare function. Save and
18101810 // restore the current one for nested calls.
18111811 old_sortinfo = sortinfo ;
@@ -2103,6 +2103,11 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap)
21032103 // map() and filter() return the first argument, also on failure.
21042104 if (filtermap != FILTERMAP_MAPNEW )
21052105 copy_tv (& argvars [0 ], rettv );
2106+
2107+ if (in_vim9script ()
2108+ && (check_for_list_or_dict_or_blob_arg (argvars , 0 ) == FAIL ))
2109+ return ;
2110+
21062111 if (filtermap == FILTERMAP_MAP && in_vim9script ())
21072112 {
21082113 // Check that map() does not change the type of the dict.
@@ -2463,6 +2468,13 @@ f_mapnew(typval_T *argvars, typval_T *rettv)
24632468f_add (typval_T * argvars , typval_T * rettv )
24642469{
24652470 rettv -> vval .v_number = 1 ; // Default: Failed
2471+
2472+ if (in_vim9script ()
2473+ && (check_for_list_or_blob_arg (argvars , 0 ) == FAIL
2474+ || (argvars [0 ].v_type == VAR_BLOB
2475+ && check_for_number_arg (argvars , 1 ) == FAIL )))
2476+ return ;
2477+
24662478 if (argvars [0 ].v_type == VAR_LIST )
24672479 {
24682480 list_T * l = argvars [0 ].vval .v_list ;
@@ -2799,6 +2811,13 @@ f_insert(typval_T *argvars, typval_T *rettv)
27992811 listitem_T * item ;
28002812 int error = FALSE;
28012813
2814+ if (in_vim9script ()
2815+ && (check_for_list_or_blob_arg (argvars , 0 ) == FAIL
2816+ || (argvars [0 ].v_type == VAR_BLOB
2817+ && check_for_number_arg (argvars , 1 ) == FAIL )
2818+ || check_for_opt_number_arg (argvars , 2 ) == FAIL ))
2819+ return ;
2820+
28022821 if (argvars [0 ].v_type == VAR_BLOB )
28032822 {
28042823 int val , len ;
@@ -2888,6 +2907,16 @@ f_remove(typval_T *argvars, typval_T *rettv)
28882907{
28892908 char_u * arg_errmsg = (char_u * )N_ ("remove() argument" );
28902909
2910+ if (in_vim9script ()
2911+ && (check_for_list_or_dict_or_blob_arg (argvars , 0 ) == FAIL
2912+ || ((argvars [0 ].v_type == VAR_LIST
2913+ || argvars [0 ].v_type == VAR_BLOB )
2914+ && (check_for_number_arg (argvars , 1 ) == FAIL
2915+ || check_for_opt_number_arg (argvars , 2 ) == FAIL ))
2916+ || (argvars [0 ].v_type == VAR_DICT
2917+ && check_for_string_or_number_arg (argvars , 1 ) == FAIL )))
2918+ return ;
2919+
28912920 if (argvars [0 ].v_type == VAR_DICT )
28922921 dict_remove (argvars , rettv , arg_errmsg );
28932922 else if (argvars [0 ].v_type == VAR_BLOB )
@@ -2907,6 +2936,9 @@ f_reverse(typval_T *argvars, typval_T *rettv)
29072936 list_T * l ;
29082937 listitem_T * li , * ni ;
29092938
2939+ if (in_vim9script () && check_for_list_or_blob_arg (argvars , 0 ) == FAIL )
2940+ return ;
2941+
29102942 if (argvars [0 ].v_type == VAR_BLOB )
29112943 {
29122944 blob_T * b = argvars [0 ].vval .v_blob ;
0 commit comments