To: vim_dev@googlegroups.com Subject: Patch 8.2.3162 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3162 Problem: Vim9: argument types are not checked at compile time. Solution: Add more type checks. (Yegappan Lakshmanan, closes #8560) Files: runtime/doc/channel.txt, src/clientserver.c, src/cmdhist.c, src/errors.h, src/evalfunc.c, src/evalwindow.c, src/filepath.c, src/globals.h, src/popupwin.c, src/proto/typval.pro, src/sign.c, src/strings.c, src/terminal.c, src/testdir/test_normal.vim, src/testdir/test_reltime.vim, src/testdir/test_vim9_builtin.vim, src/testdir/test_vim9_expr.vim, src/testing.c, src/textprop.c, src/time.c, src/typval.c *** ../vim-8.2.3161/runtime/doc/channel.txt 2021-01-31 17:02:06.246490203 +0100 --- runtime/doc/channel.txt 2021-07-15 10:53:45.234392528 +0200 *************** *** 852,858 **** job_getchannel({job}) *job_getchannel()* Get the channel handle that {job} is using. To check if the job has no channel: > ! if string(job_getchannel()) == 'channel fail' < Can also be used as a |method|: > GetJob()->job_getchannel() --- 852,858 ---- job_getchannel({job}) *job_getchannel()* Get the channel handle that {job} is using. To check if the job has no channel: > ! if string(job_getchannel(job)) == 'channel fail' < Can also be used as a |method|: > GetJob()->job_getchannel() *** ../vim-8.2.3161/src/clientserver.c 2020-06-24 20:33:59.565106319 +0200 --- src/clientserver.c 2021-07-15 10:53:45.234392528 +0200 *************** *** 596,602 **** ga_concat(&ga, cdp); // Call inputsave() so that a prompt for an encryption key works. ! ga_concat(&ga, (char_u *)":if exists('*inputsave')|call inputsave()|endif|"); if (tabs) ga_concat(&ga, (char_u *)"tab "); ga_concat(&ga, (char_u *)"drop"); --- 596,603 ---- ga_concat(&ga, cdp); // Call inputsave() so that a prompt for an encryption key works. ! ga_concat(&ga, (char_u *) ! ":if exists('*inputsave')|call inputsave()|endif|"); if (tabs) ga_concat(&ga, (char_u *)"tab "); ga_concat(&ga, (char_u *)"drop"); *************** *** 621,627 **** ga_concat(&ga, p); vim_free(p); } ! ga_concat(&ga, (char_u *)"|if exists('*inputrestore')|call inputrestore()|endif"); // The :drop commands goes to Insert mode when 'insertmode' is set, use // CTRL-\ CTRL-N again. --- 622,629 ---- ga_concat(&ga, p); vim_free(p); } ! ga_concat(&ga, (char_u *) ! "|if exists('*inputrestore')|call inputrestore()|endif"); // The :drop commands goes to Insert mode when 'insertmode' is set, use // CTRL-\ CTRL-N again. *************** *** 885,892 **** char_u *r = NULL; #ifdef FEAT_CLIENTSERVER ! char_u *serverid = tv_get_string_chk(&argvars[0]); if (serverid != NULL && !check_restricted() && !check_secure()) { int timeout = 0; --- 887,901 ---- char_u *r = NULL; #ifdef FEAT_CLIENTSERVER ! char_u *serverid; ! ! if (in_vim9script() ! && (check_for_string_arg(argvars, 0) == FAIL ! || (argvars[1].v_type != VAR_UNKNOWN ! && check_for_number_arg(argvars, 1) == FAIL))) ! return; + serverid = tv_get_string_chk(&argvars[0]); if (serverid != NULL && !check_restricted() && !check_secure()) { int timeout = 0; *** ../vim-8.2.3161/src/cmdhist.c 2021-06-02 13:28:11.423120478 +0200 --- src/cmdhist.c 2021-07-15 10:53:45.234392528 +0200 *************** *** 597,602 **** --- 597,608 ---- int idx; char_u *str; + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || (argvars[1].v_type != VAR_UNKNOWN + && check_for_number_arg(argvars, 1) == FAIL))) + return; + str = tv_get_string_chk(&argvars[0]); // NULL on type error if (str == NULL) rettv->vval.v_string = NULL; *** ../vim-8.2.3161/src/errors.h 2021-07-11 16:01:54.468064058 +0200 --- src/errors.h 2021-07-15 10:53:45.234392528 +0200 *************** *** 500,502 **** --- 500,504 ---- INIT(= N_("E1208: -complete used without -nargs")); EXTERN char e_invalid_value_for_line_number_str[] INIT(= N_("E1209: Invalid value for a line number: \"%s\"")); + EXTERN char e_number_required_for_argument_nr[] + INIT(= N_("E1210: Number required for argument %d")); *** ../vim-8.2.3161/src/evalfunc.c 2021-07-13 20:32:26.255186763 +0200 --- src/evalfunc.c 2021-07-15 10:53:45.238392517 +0200 *************** *** 255,260 **** --- 255,269 ---- } /* + * Check "type" is a list of 'any'. + */ + static int + arg_list_any(type_T *type, argcontext_T *context) + { + return check_arg_type(&t_list_any, type, context); + } + + /* * Check "type" is a list of numbers. */ static int *************** *** 287,295 **** static int arg_bool(type_T *type, argcontext_T *context) { - if (type->tt_type == VAR_ANY - || type->tt_type == VAR_NUMBER || type->tt_type == VAR_BOOL) - return OK; return check_arg_type(&t_bool, type, context); } --- 296,301 ---- *************** *** 353,359 **** } /* ! * Check "type" is a list or a dict. */ static int arg_list_or_dict(type_T *type, argcontext_T *context) --- 359,365 ---- } /* ! * Check "type" is a list of 'any' or a dict of 'any'. */ static int arg_list_or_dict(type_T *type, argcontext_T *context) *************** *** 366,377 **** } /* * Check "type" is a channel or a job. */ static int arg_chan_or_job(type_T *type, argcontext_T *context) { ! if (type->tt_type == VAR_CHANNEL || type->tt_type == VAR_JOB) return OK; arg_type_mismatch(&t_channel, type, context->arg_idx + 1); return FAIL; --- 372,393 ---- } /* + * Check "type" is a job. + */ + static int + arg_job(type_T *type, argcontext_T *context) + { + return check_arg_type(&t_job, type, context); + } + + /* * Check "type" is a channel or a job. */ static int arg_chan_or_job(type_T *type, argcontext_T *context) { ! if (type->tt_type == VAR_ANY || ! type->tt_type == VAR_CHANNEL || type->tt_type == VAR_JOB) return OK; arg_type_mismatch(&t_channel, type, context->arg_idx + 1); return FAIL; *************** *** 459,496 **** /* * Lists of functions that check the argument types of a builtin function. */ ! argcheck_T arg1_string[] = {arg_string}; ! argcheck_T arg1_number[] = {arg_number}; ! argcheck_T arg1_dict[] = {arg_dict_any}; ! argcheck_T arg1_list_nr[] = {arg_list_number}; ! argcheck_T arg1_list_string[] = {arg_list_string}; ! argcheck_T arg1_float_or_nr[] = {arg_float_or_nr}; ! argcheck_T arg1_string_or_nr[] = {arg_string_or_nr}; ! argcheck_T arg1_string_or_list_any[] = {arg_string_or_list_any}; ! argcheck_T arg1_string_or_list_string[] = {arg_string_or_list_string}; ! argcheck_T arg1_list_or_blob[] = {arg_list_or_blob}; ! argcheck_T arg1_chan_or_job[] = {arg_chan_or_job}; ! argcheck_T arg2_float_or_nr[] = {arg_float_or_nr, arg_float_or_nr}; ! argcheck_T arg2_number[] = {arg_number, arg_number}; ! argcheck_T arg2_string[] = {arg_string, arg_string}; ! argcheck_T arg2_list_nr[] = {arg_list_number, arg_list_number}; ! argcheck_T arg2_dict_string[] = {arg_dict_any, arg_string}; ! argcheck_T arg2_dict_string_or_nr[] = {arg_dict_any, arg_string_or_nr}; ! argcheck_T arg2_string_dict[] = {arg_string, arg_dict_any}; ! argcheck_T arg2_listblob_item[] = {arg_list_or_blob, arg_item_of_prev}; ! argcheck_T arg2_str_or_nr_or_list_dict[] = {arg_str_or_nr_or_list, arg_dict_any}; ! argcheck_T arg2_string_or_list_dict[] = {arg_string_or_list_any, arg_dict_any}; ! argcheck_T arg3_string[] = {arg_string, arg_string, arg_string}; ! argcheck_T arg3_number[] = {arg_number, arg_number, arg_number}; ! argcheck_T arg3_string_nr_bool[] = {arg_string, arg_number, arg_bool}; ! argcheck_T arg3_string_string_nr[] = {arg_string, arg_string, arg_number}; ! argcheck_T arg2_execute[] = {arg_string_or_list_string, arg_string}; ! argcheck_T arg23_win_execute[] = {arg_number, arg_string_or_list_string, arg_string}; ! argcheck_T arg2_setline[] = {arg_string_or_nr, arg_string_or_list_any}; ! argcheck_T arg3_setbufline[] = {arg_string_or_nr, arg_string_or_nr, arg_string_or_list_any}; ! argcheck_T arg23_extend[] = {arg_list_or_dict, arg_same_as_prev, arg_extend3}; ! argcheck_T arg23_extendnew[] = {arg_list_or_dict, arg_same_struct_as_prev, arg_extend3}; ! argcheck_T arg3_insert[] = {arg_list_or_blob, arg_item_of_prev, arg_number}; /* * Functions that return the return type of a builtin function. --- 475,521 ---- /* * Lists of functions that check the argument types of a builtin function. */ ! static argcheck_T arg1_string[] = {arg_string}; ! static argcheck_T arg1_number[] = {arg_number}; ! static argcheck_T arg1_bool[] = {arg_bool}; ! static argcheck_T arg1_dict_any[] = {arg_dict_any}; ! static argcheck_T arg1_job[] = {arg_job}; ! static argcheck_T arg1_list_any[] = {arg_list_any}; ! static argcheck_T arg1_list_nr[] = {arg_list_number}; ! static argcheck_T arg1_list_string[] = {arg_list_string}; ! static argcheck_T arg1_float_or_nr[] = {arg_float_or_nr}; ! static argcheck_T arg1_string_or_nr[] = {arg_string_or_nr}; ! static argcheck_T arg1_string_or_list_any[] = {arg_string_or_list_any}; ! static argcheck_T arg1_string_or_list_string[] = {arg_string_or_list_string}; ! static argcheck_T arg1_list_or_blob[] = {arg_list_or_blob}; ! static argcheck_T arg1_list_or_dict[] = {arg_list_or_dict}; ! static argcheck_T arg1_chan_or_job[] = {arg_chan_or_job}; ! static argcheck_T arg2_float_or_nr[] = {arg_float_or_nr, arg_float_or_nr}; ! static argcheck_T arg2_number[] = {arg_number, arg_number}; ! static argcheck_T arg2_string[] = {arg_string, arg_string}; ! static argcheck_T arg2_list_nr[] = {arg_list_number, arg_list_number}; ! static argcheck_T arg2_nr_string[] = {arg_number, arg_string}; ! static argcheck_T arg2_dict_string[] = {arg_dict_any, arg_string}; ! static argcheck_T arg2_dict_string_or_nr[] = {arg_dict_any, arg_string_or_nr}; ! static argcheck_T arg2_string_dict[] = {arg_string, arg_dict_any}; ! static argcheck_T arg2_string_nr[] = {arg_string, arg_number}; ! //static argcheck_T arg2_listblob_item[] = {arg_list_or_blob, arg_item_of_prev}; ! static argcheck_T arg2_str_or_nr_or_list_dict[] = {arg_str_or_nr_or_list, arg_dict_any}; ! static argcheck_T arg2_string_or_list_dict[] = {arg_string_or_list_any, arg_dict_any}; ! static argcheck_T arg2_chan_or_job_dict[] = {arg_chan_or_job, arg_dict_any}; ! static argcheck_T arg2_nr_dict_any[] = {arg_number, arg_dict_any}; ! //static argcheck_T arg2_string_number[] = {arg_string, arg_number}; ! static argcheck_T arg3_string[] = {arg_string, arg_string, arg_string}; ! static argcheck_T arg3_number[] = {arg_number, arg_number, arg_number}; ! static argcheck_T arg3_string_nr_bool[] = {arg_string, arg_number, arg_bool}; ! static argcheck_T arg3_string_string_nr[] = {arg_string, arg_string, arg_number}; ! static argcheck_T arg2_execute[] = {arg_string_or_list_string, arg_string}; ! static argcheck_T arg23_win_execute[] = {arg_number, arg_string_or_list_string, arg_string}; ! static argcheck_T arg2_setline[] = {arg_string_or_nr, NULL}; ! static argcheck_T arg3_setbufline[] = {arg_string_or_nr, arg_string_or_nr, arg_str_or_nr_or_list}; ! static argcheck_T arg23_extend[] = {arg_list_or_dict, arg_same_as_prev, arg_extend3}; ! static argcheck_T arg23_extendnew[] = {arg_list_or_dict, arg_same_struct_as_prev, arg_extend3}; ! static argcheck_T arg3_insert[] = {arg_list_or_blob, arg_item_of_prev, arg_number}; /* * Functions that return the return type of a builtin function. *************** *** 762,770 **** ret_first_arg, f_add}, {"and", 2, 2, FEARG_1, arg2_number, ret_number, f_and}, ! {"append", 2, 2, FEARG_2, NULL, ret_number_bool, f_append}, ! {"appendbufline", 3, 3, FEARG_3, NULL, ret_number_bool, f_appendbufline}, {"argc", 0, 1, 0, arg1_number, ret_number, f_argc}, --- 787,795 ---- ret_first_arg, f_add}, {"and", 2, 2, FEARG_1, arg2_number, ret_number, f_and}, ! {"append", 2, 2, FEARG_2, arg2_setline, ret_number_bool, f_append}, ! {"appendbufline", 3, 3, FEARG_3, arg3_setbufline, ret_number_bool, f_appendbufline}, {"argc", 0, 1, 0, arg1_number, ret_number, f_argc}, *************** *** 776,782 **** ret_argv, f_argv}, {"asin", 1, 1, FEARG_1, arg1_float_or_nr, ret_float, FLOAT_FUNC(f_asin)}, ! {"assert_beeps", 1, 2, FEARG_1, NULL, ret_number_bool, f_assert_beeps}, {"assert_equal", 2, 3, FEARG_2, NULL, ret_number_bool, f_assert_equal}, --- 801,807 ---- ret_argv, f_argv}, {"asin", 1, 1, FEARG_1, arg1_float_or_nr, ret_float, FLOAT_FUNC(f_asin)}, ! {"assert_beeps", 1, 1, FEARG_1, arg1_string, ret_number_bool, f_assert_beeps}, {"assert_equal", 2, 3, FEARG_2, NULL, ret_number_bool, f_assert_equal}, *************** *** 792,798 **** ret_number_bool, f_assert_inrange}, {"assert_match", 2, 3, FEARG_2, arg3_string, ret_number_bool, f_assert_match}, ! {"assert_nobeep", 1, 2, FEARG_1, NULL, ret_number_bool, f_assert_nobeep}, {"assert_notequal", 2, 3, FEARG_2, NULL, ret_number_bool, f_assert_notequal}, --- 817,823 ---- ret_number_bool, f_assert_inrange}, {"assert_match", 2, 3, FEARG_2, arg3_string, ret_number_bool, f_assert_match}, ! {"assert_nobeep", 1, 1, FEARG_1, arg1_string, ret_number_bool, f_assert_nobeep}, {"assert_notequal", 2, 3, FEARG_2, NULL, ret_number_bool, f_assert_notequal}, *************** *** 860,868 **** ret_number, f_bufwinnr}, {"byte2line", 1, 1, FEARG_1, arg1_number, ret_number, f_byte2line}, ! {"byteidx", 2, 2, FEARG_1, NULL, ret_number, f_byteidx}, ! {"byteidxcomp", 2, 2, FEARG_1, NULL, ret_number, f_byteidxcomp}, {"call", 2, 3, FEARG_1, NULL, ret_any, f_call}, --- 885,893 ---- ret_number, f_bufwinnr}, {"byte2line", 1, 1, FEARG_1, arg1_number, ret_number, f_byte2line}, ! {"byteidx", 2, 2, FEARG_1, arg2_string_nr, ret_number, f_byteidx}, ! {"byteidxcomp", 2, 2, FEARG_1, arg2_string_nr, ret_number, f_byteidxcomp}, {"call", 2, 3, FEARG_1, NULL, ret_any, f_call}, *************** *** 880,886 **** ret_any, JOB_FUNC(f_ch_evalraw)}, {"ch_getbufnr", 2, 2, FEARG_1, NULL, ret_number, JOB_FUNC(f_ch_getbufnr)}, ! {"ch_getjob", 1, 1, FEARG_1, NULL, ret_job, JOB_FUNC(f_ch_getjob)}, {"ch_info", 1, 1, FEARG_1, arg1_chan_or_job, ret_dict_any, JOB_FUNC(f_ch_info)}, --- 905,911 ---- ret_any, JOB_FUNC(f_ch_evalraw)}, {"ch_getbufnr", 2, 2, FEARG_1, NULL, ret_number, JOB_FUNC(f_ch_getbufnr)}, ! {"ch_getjob", 1, 1, FEARG_1, arg1_chan_or_job, ret_job, JOB_FUNC(f_ch_getjob)}, {"ch_info", 1, 1, FEARG_1, arg1_chan_or_job, ret_dict_any, JOB_FUNC(f_ch_info)}, *************** *** 890,908 **** ret_void, JOB_FUNC(f_ch_logfile)}, {"ch_open", 1, 2, FEARG_1, arg2_string_dict, ret_channel, JOB_FUNC(f_ch_open)}, ! {"ch_read", 1, 2, FEARG_1, NULL, ret_string, JOB_FUNC(f_ch_read)}, ! {"ch_readblob", 1, 2, FEARG_1, NULL, ret_blob, JOB_FUNC(f_ch_readblob)}, ! {"ch_readraw", 1, 2, FEARG_1, NULL, ret_string, JOB_FUNC(f_ch_readraw)}, {"ch_sendexpr", 2, 3, FEARG_1, NULL, ret_void, JOB_FUNC(f_ch_sendexpr)}, {"ch_sendraw", 2, 3, FEARG_1, NULL, ret_void, JOB_FUNC(f_ch_sendraw)}, ! {"ch_setoptions", 2, 2, FEARG_1, NULL, ret_void, JOB_FUNC(f_ch_setoptions)}, ! {"ch_status", 1, 2, FEARG_1, NULL, ret_string, JOB_FUNC(f_ch_status)}, {"changenr", 0, 0, 0, NULL, ret_number, f_changenr}, --- 915,933 ---- ret_void, JOB_FUNC(f_ch_logfile)}, {"ch_open", 1, 2, FEARG_1, arg2_string_dict, ret_channel, JOB_FUNC(f_ch_open)}, ! {"ch_read", 1, 2, FEARG_1, arg2_chan_or_job_dict, ret_string, JOB_FUNC(f_ch_read)}, ! {"ch_readblob", 1, 2, FEARG_1, arg2_chan_or_job_dict, ret_blob, JOB_FUNC(f_ch_readblob)}, ! {"ch_readraw", 1, 2, FEARG_1, arg2_chan_or_job_dict, ret_string, JOB_FUNC(f_ch_readraw)}, {"ch_sendexpr", 2, 3, FEARG_1, NULL, ret_void, JOB_FUNC(f_ch_sendexpr)}, {"ch_sendraw", 2, 3, FEARG_1, NULL, ret_void, JOB_FUNC(f_ch_sendraw)}, ! {"ch_setoptions", 2, 2, FEARG_1, arg2_chan_or_job_dict, ret_void, JOB_FUNC(f_ch_setoptions)}, ! {"ch_status", 1, 2, FEARG_1, arg2_chan_or_job_dict, ret_string, JOB_FUNC(f_ch_status)}, {"changenr", 0, 0, 0, NULL, ret_number, f_changenr}, *************** *** 964,970 **** ret_number, f_diff_filler}, {"diff_hlID", 2, 2, FEARG_1, NULL, ret_number, f_diff_hlID}, ! {"echoraw", 1, 1, FEARG_1, NULL, ret_void, f_echoraw}, {"empty", 1, 1, FEARG_1, NULL, ret_number_bool, f_empty}, --- 989,995 ---- ret_number, f_diff_filler}, {"diff_hlID", 2, 2, FEARG_1, NULL, ret_number, f_diff_hlID}, ! {"echoraw", 1, 1, FEARG_1, arg1_string, ret_void, f_echoraw}, {"empty", 1, 1, FEARG_1, NULL, ret_number_bool, f_empty}, *************** *** 1040,1046 **** ret_func_any, f_funcref}, {"function", 1, 3, FEARG_1, NULL, ret_f_function, f_function}, ! {"garbagecollect", 0, 1, 0, NULL, ret_void, f_garbagecollect}, {"get", 2, 3, FEARG_1, NULL, ret_any, f_get}, --- 1065,1071 ---- ret_func_any, f_funcref}, {"function", 1, 3, FEARG_1, NULL, ret_f_function, f_function}, ! {"garbagecollect", 0, 1, 0, arg1_bool, ret_void, f_garbagecollect}, {"get", 2, 3, FEARG_1, NULL, ret_any, f_get}, *************** *** 1052,1066 **** ret_any, f_getbufvar}, {"getchangelist", 0, 1, FEARG_1, arg1_string_or_nr, ret_list_any, f_getchangelist}, ! {"getchar", 0, 1, 0, NULL, ret_any, f_getchar}, {"getcharmod", 0, 0, 0, NULL, ret_number, f_getcharmod}, ! {"getcharpos", 1, 1, FEARG_1, NULL, ret_list_number, f_getcharpos}, {"getcharsearch", 0, 0, 0, NULL, ret_dict_any, f_getcharsearch}, ! {"getcharstr", 0, 1, 0, NULL, ret_string, f_getcharstr}, {"getcmdline", 0, 0, 0, NULL, ret_string, f_getcmdline}, --- 1077,1091 ---- ret_any, f_getbufvar}, {"getchangelist", 0, 1, FEARG_1, arg1_string_or_nr, ret_list_any, f_getchangelist}, ! {"getchar", 0, 1, 0, arg1_bool, ret_any, f_getchar}, {"getcharmod", 0, 0, 0, NULL, ret_number, f_getcharmod}, ! {"getcharpos", 1, 1, FEARG_1, arg1_string, ret_list_number, f_getcharpos}, {"getcharsearch", 0, 0, 0, NULL, ret_dict_any, f_getcharsearch}, ! {"getcharstr", 0, 1, 0, arg1_bool, ret_string, f_getcharstr}, {"getcmdline", 0, 0, 0, NULL, ret_string, f_getcmdline}, *************** *** 1096,1102 **** ret_list_any, f_getjumplist}, {"getline", 1, 2, FEARG_1, NULL, ret_f_getline, f_getline}, ! {"getloclist", 1, 2, 0, NULL, ret_list_or_dict_1, f_getloclist}, {"getmarklist", 0, 1, FEARG_1, arg1_string_or_nr, ret_list_dict_any, f_getmarklist}, --- 1121,1127 ---- ret_list_any, f_getjumplist}, {"getline", 1, 2, FEARG_1, NULL, ret_f_getline, f_getline}, ! {"getloclist", 1, 2, 0, arg2_nr_dict_any, ret_list_or_dict_1, f_getloclist}, {"getmarklist", 0, 1, FEARG_1, arg1_string_or_nr, ret_list_dict_any, f_getmarklist}, *************** *** 1108,1114 **** ret_number, f_getpid}, {"getpos", 1, 1, FEARG_1, arg1_string, ret_list_number, f_getpos}, ! {"getqflist", 0, 1, 0, arg1_dict, ret_list_or_dict_0, f_getqflist}, {"getreg", 0, 3, FEARG_1, NULL, ret_getreg, f_getreg}, --- 1133,1139 ---- ret_number, f_getpid}, {"getpos", 1, 1, FEARG_1, arg1_string, ret_list_number, f_getpos}, ! {"getqflist", 0, 1, 0, arg1_dict_any, ret_list_or_dict_0, f_getqflist}, {"getreg", 0, 3, FEARG_1, NULL, ret_getreg, f_getreg}, *************** *** 1158,1164 **** ret_number_bool, f_histadd}, {"histdel", 1, 2, FEARG_1, NULL, ret_number_bool, f_histdel}, ! {"histget", 1, 2, FEARG_1, NULL, ret_string, f_histget}, {"histnr", 1, 1, FEARG_1, arg1_string, ret_number, f_histnr}, --- 1183,1189 ---- ret_number_bool, f_histadd}, {"histdel", 1, 2, FEARG_1, NULL, ret_number_bool, f_histdel}, ! {"histget", 1, 2, FEARG_1, arg2_string_nr, ret_string, f_histget}, {"histnr", 1, 1, FEARG_1, arg1_string, ret_number, f_histnr}, *************** *** 1196,1216 **** ret_number_bool, f_isdirectory}, {"isinf", 1, 1, FEARG_1, arg1_float_or_nr, ret_number, MATH_FUNC(f_isinf)}, ! {"islocked", 1, 1, FEARG_1, NULL, ret_number_bool, f_islocked}, {"isnan", 1, 1, FEARG_1, arg1_float_or_nr, ret_number_bool, MATH_FUNC(f_isnan)}, ! {"items", 1, 1, FEARG_1, arg1_dict, ret_list_items, f_items}, ! {"job_getchannel", 1, 1, FEARG_1, NULL, ret_channel, JOB_FUNC(f_job_getchannel)}, ! {"job_info", 0, 1, FEARG_1, NULL, ret_job_info, JOB_FUNC(f_job_info)}, {"job_setoptions", 2, 2, FEARG_1, NULL, ret_void, JOB_FUNC(f_job_setoptions)}, {"job_start", 1, 2, FEARG_1, NULL, ret_job, JOB_FUNC(f_job_start)}, ! {"job_status", 1, 1, FEARG_1, NULL, ret_string, JOB_FUNC(f_job_status)}, {"job_stop", 1, 2, FEARG_1, NULL, ret_number_bool, JOB_FUNC(f_job_stop)}, --- 1221,1241 ---- ret_number_bool, f_isdirectory}, {"isinf", 1, 1, FEARG_1, arg1_float_or_nr, ret_number, MATH_FUNC(f_isinf)}, ! {"islocked", 1, 1, FEARG_1, arg1_string, ret_number_bool, f_islocked}, {"isnan", 1, 1, FEARG_1, arg1_float_or_nr, ret_number_bool, MATH_FUNC(f_isnan)}, ! {"items", 1, 1, FEARG_1, arg1_dict_any, ret_list_items, f_items}, ! {"job_getchannel", 1, 1, FEARG_1, arg1_job, ret_channel, JOB_FUNC(f_job_getchannel)}, ! {"job_info", 0, 1, FEARG_1, arg1_job, ret_job_info, JOB_FUNC(f_job_info)}, {"job_setoptions", 2, 2, FEARG_1, NULL, ret_void, JOB_FUNC(f_job_setoptions)}, {"job_start", 1, 2, FEARG_1, NULL, ret_job, JOB_FUNC(f_job_start)}, ! {"job_status", 1, 1, FEARG_1, arg1_job, ret_string, JOB_FUNC(f_job_status)}, {"job_stop", 1, 2, FEARG_1, NULL, ret_number_bool, JOB_FUNC(f_job_stop)}, *************** *** 1224,1230 **** ret_any, f_json_decode}, {"json_encode", 1, 1, FEARG_1, NULL, ret_string, f_json_encode}, ! {"keys", 1, 1, FEARG_1, arg1_dict, ret_list_string, f_keys}, {"last_buffer_nr", 0, 0, 0, arg1_string_or_nr, // obsolete ret_number, f_last_buffer_nr}, --- 1249,1255 ---- ret_any, f_json_decode}, {"json_encode", 1, 1, FEARG_1, NULL, ret_string, f_json_encode}, ! {"keys", 1, 1, FEARG_1, arg1_dict_any, ret_list_string, f_keys}, {"last_buffer_nr", 0, 0, 0, arg1_string_or_nr, // obsolete ret_number, f_last_buffer_nr}, *************** *** 1234,1240 **** ret_string, f_libcall}, {"libcallnr", 3, 3, FEARG_3, NULL, ret_number, f_libcallnr}, ! {"line", 1, 2, FEARG_1, NULL, ret_number, f_line}, {"line2byte", 1, 1, FEARG_1, arg1_string_or_nr, ret_number, f_line2byte}, --- 1259,1265 ---- ret_string, f_libcall}, {"libcallnr", 3, 3, FEARG_3, NULL, ret_number, f_libcallnr}, ! {"line", 1, 2, FEARG_1, arg2_string_nr, ret_number, f_line}, {"line2byte", 1, 1, FEARG_1, arg1_string_or_nr, ret_number, f_line2byte}, *************** *** 1294,1300 **** ret_string, f_matchstr}, {"matchstrpos", 2, 4, FEARG_1, NULL, ret_list_any, f_matchstrpos}, ! {"max", 1, 1, FEARG_1, NULL, ret_number, f_max}, {"menu_info", 1, 2, FEARG_1, arg2_string, ret_dict_any, --- 1319,1325 ---- ret_string, f_matchstr}, {"matchstrpos", 2, 4, FEARG_1, NULL, ret_list_any, f_matchstrpos}, ! {"max", 1, 1, FEARG_1, arg1_list_or_dict, ret_number, f_max}, {"menu_info", 1, 2, FEARG_1, arg2_string, ret_dict_any, *************** *** 1304,1316 **** NULL #endif }, ! {"min", 1, 1, FEARG_1, NULL, ret_number, f_min}, {"mkdir", 1, 3, FEARG_1, arg3_string_string_nr, ret_number_bool, f_mkdir}, ! {"mode", 0, 1, FEARG_1, NULL, ret_string, f_mode}, ! {"mzeval", 1, 1, FEARG_1, NULL, ret_any, #ifdef FEAT_MZSCHEME f_mzeval --- 1329,1341 ---- NULL #endif }, ! {"min", 1, 1, FEARG_1, arg1_list_or_dict, ret_number, f_min}, {"mkdir", 1, 3, FEARG_1, arg3_string_string_nr, ret_number_bool, f_mkdir}, ! {"mode", 0, 1, FEARG_1, arg1_bool, ret_string, f_mode}, ! {"mzeval", 1, 1, FEARG_1, arg1_string, ret_any, #ifdef FEAT_MZSCHEME f_mzeval *************** *** 1324,1332 **** ret_string, f_nr2char}, {"or", 2, 2, FEARG_1, arg2_number, ret_number, f_or}, ! {"pathshorten", 1, 2, FEARG_1, NULL, ret_string, f_pathshorten}, ! {"perleval", 1, 1, FEARG_1, NULL, ret_any, #ifdef FEAT_PERL f_perleval --- 1349,1357 ---- ret_string, f_nr2char}, {"or", 2, 2, FEARG_1, arg2_number, ret_number, f_or}, ! {"pathshorten", 1, 2, FEARG_1, arg2_string_nr, ret_string, f_pathshorten}, ! {"perleval", 1, 1, FEARG_1, arg1_string, ret_any, #ifdef FEAT_PERL f_perleval *************** *** 1338,1344 **** ret_number, PROP_FUNC(f_popup_atcursor)}, {"popup_beval", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict, ret_number, PROP_FUNC(f_popup_beval)}, ! {"popup_clear", 0, 1, 0, NULL, ret_void, PROP_FUNC(f_popup_clear)}, {"popup_close", 1, 2, FEARG_1, NULL, ret_void, PROP_FUNC(f_popup_close)}, --- 1363,1369 ---- ret_number, PROP_FUNC(f_popup_atcursor)}, {"popup_beval", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict, ret_number, PROP_FUNC(f_popup_beval)}, ! {"popup_clear", 0, 1, 0, arg1_bool, ret_void, PROP_FUNC(f_popup_clear)}, {"popup_close", 1, 2, FEARG_1, NULL, ret_void, PROP_FUNC(f_popup_close)}, *************** *** 1346,1364 **** ret_number, PROP_FUNC(f_popup_create)}, {"popup_dialog", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict, ret_number, PROP_FUNC(f_popup_dialog)}, ! {"popup_filter_menu", 2, 2, 0, NULL, ret_bool, PROP_FUNC(f_popup_filter_menu)}, ! {"popup_filter_yesno", 2, 2, 0, NULL, ret_bool, PROP_FUNC(f_popup_filter_yesno)}, {"popup_findinfo", 0, 0, 0, NULL, ret_number, PROP_FUNC(f_popup_findinfo)}, {"popup_findpreview", 0, 0, 0, NULL, ret_number, PROP_FUNC(f_popup_findpreview)}, ! {"popup_getoptions", 1, 1, FEARG_1, NULL, ret_dict_any, PROP_FUNC(f_popup_getoptions)}, ! {"popup_getpos", 1, 1, FEARG_1, NULL, ret_dict_any, PROP_FUNC(f_popup_getpos)}, ! {"popup_hide", 1, 1, FEARG_1, NULL, ret_void, PROP_FUNC(f_popup_hide)}, {"popup_list", 0, 0, 0, NULL, ret_list_number, PROP_FUNC(f_popup_list)}, --- 1371,1389 ---- ret_number, PROP_FUNC(f_popup_create)}, {"popup_dialog", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict, ret_number, PROP_FUNC(f_popup_dialog)}, ! {"popup_filter_menu", 2, 2, 0, arg2_nr_string, ret_bool, PROP_FUNC(f_popup_filter_menu)}, ! {"popup_filter_yesno", 2, 2, 0, arg2_nr_string, ret_bool, PROP_FUNC(f_popup_filter_yesno)}, {"popup_findinfo", 0, 0, 0, NULL, ret_number, PROP_FUNC(f_popup_findinfo)}, {"popup_findpreview", 0, 0, 0, NULL, ret_number, PROP_FUNC(f_popup_findpreview)}, ! {"popup_getoptions", 1, 1, FEARG_1, arg1_number, ret_dict_any, PROP_FUNC(f_popup_getoptions)}, ! {"popup_getpos", 1, 1, FEARG_1, arg1_number, ret_dict_any, PROP_FUNC(f_popup_getpos)}, ! {"popup_hide", 1, 1, FEARG_1, arg1_number, ret_void, PROP_FUNC(f_popup_hide)}, {"popup_list", 0, 0, 0, NULL, ret_list_number, PROP_FUNC(f_popup_list)}, *************** *** 1366,1380 **** ret_number, PROP_FUNC(f_popup_locate)}, {"popup_menu", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict, ret_number, PROP_FUNC(f_popup_menu)}, ! {"popup_move", 2, 2, FEARG_1, NULL, ret_void, PROP_FUNC(f_popup_move)}, {"popup_notification", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict, ret_number, PROP_FUNC(f_popup_notification)}, ! {"popup_setoptions", 2, 2, FEARG_1, NULL, ret_void, PROP_FUNC(f_popup_setoptions)}, {"popup_settext", 2, 2, FEARG_1, NULL, ret_void, PROP_FUNC(f_popup_settext)}, ! {"popup_show", 1, 1, FEARG_1, NULL, ret_void, PROP_FUNC(f_popup_show)}, {"pow", 2, 2, FEARG_1, arg2_float_or_nr, ret_float, FLOAT_FUNC(f_pow)}, --- 1391,1405 ---- ret_number, PROP_FUNC(f_popup_locate)}, {"popup_menu", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict, ret_number, PROP_FUNC(f_popup_menu)}, ! {"popup_move", 2, 2, FEARG_1, arg2_nr_dict_any, ret_void, PROP_FUNC(f_popup_move)}, {"popup_notification", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict, ret_number, PROP_FUNC(f_popup_notification)}, ! {"popup_setoptions", 2, 2, FEARG_1, arg2_nr_dict_any, ret_void, PROP_FUNC(f_popup_setoptions)}, {"popup_settext", 2, 2, FEARG_1, NULL, ret_void, PROP_FUNC(f_popup_settext)}, ! {"popup_show", 1, 1, FEARG_1, arg1_number, ret_void, PROP_FUNC(f_popup_show)}, {"pow", 2, 2, FEARG_1, arg2_float_or_nr, ret_float, FLOAT_FUNC(f_pow)}, *************** *** 1396,1402 **** ret_void, PROP_FUNC(f_prop_clear)}, {"prop_find", 1, 2, FEARG_1, arg2_dict_string, ret_dict_any, PROP_FUNC(f_prop_find)}, ! {"prop_list", 1, 2, FEARG_1, NULL, ret_list_dict_any, PROP_FUNC(f_prop_list)}, {"prop_remove", 1, 3, FEARG_1, NULL, ret_number, PROP_FUNC(f_prop_remove)}, --- 1421,1427 ---- ret_void, PROP_FUNC(f_prop_clear)}, {"prop_find", 1, 2, FEARG_1, arg2_dict_string, ret_dict_any, PROP_FUNC(f_prop_find)}, ! {"prop_list", 1, 2, FEARG_1, arg2_nr_dict_any, ret_list_dict_any, PROP_FUNC(f_prop_list)}, {"prop_remove", 1, 3, FEARG_1, NULL, ret_number, PROP_FUNC(f_prop_remove)}, *************** *** 1408,1420 **** ret_void, PROP_FUNC(f_prop_type_delete)}, {"prop_type_get", 1, 2, FEARG_1, arg2_string_dict, ret_dict_any, PROP_FUNC(f_prop_type_get)}, ! {"prop_type_list", 0, 1, FEARG_1, NULL, ret_list_string, PROP_FUNC(f_prop_type_list)}, {"pum_getpos", 0, 0, 0, NULL, ret_dict_number, f_pum_getpos}, {"pumvisible", 0, 0, 0, NULL, ret_number_bool, f_pumvisible}, ! {"py3eval", 1, 1, FEARG_1, NULL, ret_any, #ifdef FEAT_PYTHON3 f_py3eval --- 1433,1445 ---- ret_void, PROP_FUNC(f_prop_type_delete)}, {"prop_type_get", 1, 2, FEARG_1, arg2_string_dict, ret_dict_any, PROP_FUNC(f_prop_type_get)}, ! {"prop_type_list", 0, 1, FEARG_1, arg1_dict_any, ret_list_string, PROP_FUNC(f_prop_type_list)}, {"pum_getpos", 0, 0, 0, NULL, ret_dict_number, f_pum_getpos}, {"pumvisible", 0, 0, 0, NULL, ret_number_bool, f_pumvisible}, ! {"py3eval", 1, 1, FEARG_1, arg1_string, ret_any, #ifdef FEAT_PYTHON3 f_py3eval *************** *** 1422,1428 **** NULL #endif }, ! {"pyeval", 1, 1, FEARG_1, NULL, ret_any, #ifdef FEAT_PYTHON f_pyeval --- 1447,1453 ---- NULL #endif }, ! {"pyeval", 1, 1, FEARG_1, arg1_string, ret_any, #ifdef FEAT_PYTHON f_pyeval *************** *** 1430,1436 **** NULL #endif }, ! {"pyxeval", 1, 1, FEARG_1, NULL, ret_any, #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) f_pyxeval --- 1455,1461 ---- NULL #endif }, ! {"pyxeval", 1, 1, FEARG_1, arg1_string, ret_any, #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) f_pyxeval *************** *** 1468,1474 **** ret_string, f_remote_foreground}, {"remote_peek", 1, 2, FEARG_1, arg2_string, ret_number, f_remote_peek}, ! {"remote_read", 1, 2, FEARG_1, NULL, ret_string, f_remote_read}, {"remote_send", 2, 3, FEARG_1, NULL, ret_string, f_remote_send}, --- 1493,1499 ---- ret_string, f_remote_foreground}, {"remote_peek", 1, 2, FEARG_1, arg2_string, ret_number, f_remote_peek}, ! {"remote_read", 1, 2, FEARG_1, arg2_string_nr, ret_string, f_remote_read}, {"remote_send", 2, 3, FEARG_1, NULL, ret_string, f_remote_send}, *************** *** 1486,1492 **** ret_first_arg, f_reverse}, {"round", 1, 1, FEARG_1, arg1_float_or_nr, ret_float, FLOAT_FUNC(f_round)}, ! {"rubyeval", 1, 1, FEARG_1, NULL, ret_any, #ifdef FEAT_RUBY f_rubyeval --- 1511,1517 ---- ret_first_arg, f_reverse}, {"round", 1, 1, FEARG_1, arg1_float_or_nr, ret_float, FLOAT_FUNC(f_round)}, ! {"rubyeval", 1, 1, FEARG_1, arg1_string, ret_any, #ifdef FEAT_RUBY f_rubyeval *************** *** 1510,1516 **** ret_string, f_screenstring}, {"search", 1, 5, FEARG_1, NULL, ret_number, f_search}, ! {"searchcount", 0, 1, FEARG_1, arg1_dict, ret_dict_any, f_searchcount}, {"searchdecl", 1, 3, FEARG_1, NULL, ret_number_bool, f_searchdecl}, --- 1535,1541 ---- ret_string, f_screenstring}, {"search", 1, 5, FEARG_1, NULL, ret_number, f_search}, ! {"searchcount", 0, 1, FEARG_1, arg1_dict_any, ret_dict_any, f_searchcount}, {"searchdecl", 1, 3, FEARG_1, NULL, ret_number_bool, f_searchdecl}, *************** *** 1524,1538 **** ret_number_bool, f_server2client}, {"serverlist", 0, 0, 0, NULL, ret_string, f_serverlist}, ! {"setbufline", 3, 3, FEARG_3, NULL, ret_number_bool, f_setbufline}, {"setbufvar", 3, 3, FEARG_3, NULL, ret_void, f_setbufvar}, ! {"setcellwidths", 1, 1, FEARG_1, NULL, ret_void, f_setcellwidths}, {"setcharpos", 2, 2, FEARG_2, NULL, ret_number_bool, f_setcharpos}, ! {"setcharsearch", 1, 1, FEARG_1, arg1_dict, ret_void, f_setcharsearch}, {"setcmdpos", 1, 1, FEARG_1, arg1_number, ret_number_bool, f_setcmdpos}, --- 1549,1563 ---- ret_number_bool, f_server2client}, {"serverlist", 0, 0, 0, NULL, ret_string, f_serverlist}, ! {"setbufline", 3, 3, FEARG_3, arg3_setbufline, ret_number_bool, f_setbufline}, {"setbufvar", 3, 3, FEARG_3, NULL, ret_void, f_setbufvar}, ! {"setcellwidths", 1, 1, FEARG_1, arg1_list_any, ret_void, f_setcellwidths}, {"setcharpos", 2, 2, FEARG_2, NULL, ret_number_bool, f_setcharpos}, ! {"setcharsearch", 1, 1, FEARG_1, arg1_dict_any, ret_void, f_setcharsearch}, {"setcmdpos", 1, 1, FEARG_1, arg1_number, ret_number_bool, f_setcmdpos}, *************** *** 1542,1548 **** ret_void, f_setenv}, {"setfperm", 2, 2, FEARG_1, arg2_string, ret_number_bool, f_setfperm}, ! {"setline", 2, 2, FEARG_2, NULL, ret_number_bool, f_setline}, {"setloclist", 2, 4, FEARG_2, NULL, ret_number_bool, f_setloclist}, --- 1567,1573 ---- ret_void, f_setenv}, {"setfperm", 2, 2, FEARG_1, arg2_string, ret_number_bool, f_setfperm}, ! {"setline", 2, 2, FEARG_2, arg2_setline, ret_number_bool, f_setline}, {"setloclist", 2, 4, FEARG_2, NULL, ret_number_bool, f_setloclist}, *************** *** 1576,1582 **** ret_number, f_shiftwidth}, {"sign_define", 1, 2, FEARG_1, arg2_string_or_list_dict, ret_any, SIGN_FUNC(f_sign_define)}, ! {"sign_getdefined", 0, 1, FEARG_1, NULL, ret_list_dict_any, SIGN_FUNC(f_sign_getdefined)}, {"sign_getplaced", 0, 2, FEARG_1, NULL, ret_list_dict_any, SIGN_FUNC(f_sign_getplaced)}, --- 1601,1607 ---- ret_number, f_shiftwidth}, {"sign_define", 1, 2, FEARG_1, arg2_string_or_list_dict, ret_any, SIGN_FUNC(f_sign_define)}, ! {"sign_getdefined", 0, 1, FEARG_1, arg1_string, ret_list_dict_any, SIGN_FUNC(f_sign_getdefined)}, {"sign_getplaced", 0, 2, FEARG_1, NULL, ret_list_dict_any, SIGN_FUNC(f_sign_getplaced)}, *************** *** 1584,1596 **** ret_number, SIGN_FUNC(f_sign_jump)}, {"sign_place", 4, 5, FEARG_1, NULL, ret_number, SIGN_FUNC(f_sign_place)}, ! {"sign_placelist", 1, 1, FEARG_1, NULL, ret_list_number, SIGN_FUNC(f_sign_placelist)}, {"sign_undefine", 0, 1, FEARG_1, arg1_string_or_list_string, ret_number_bool, SIGN_FUNC(f_sign_undefine)}, {"sign_unplace", 1, 2, FEARG_1, arg2_string_dict, ret_number_bool, SIGN_FUNC(f_sign_unplace)}, ! {"sign_unplacelist", 1, 2, FEARG_1, NULL, ret_list_number, SIGN_FUNC(f_sign_unplacelist)}, {"simplify", 1, 1, FEARG_1, arg1_string, ret_string, f_simplify}, --- 1609,1621 ---- ret_number, SIGN_FUNC(f_sign_jump)}, {"sign_place", 4, 5, FEARG_1, NULL, ret_number, SIGN_FUNC(f_sign_place)}, ! {"sign_placelist", 1, 1, FEARG_1, arg1_list_any, ret_list_number, SIGN_FUNC(f_sign_placelist)}, {"sign_undefine", 0, 1, FEARG_1, arg1_string_or_list_string, ret_number_bool, SIGN_FUNC(f_sign_undefine)}, {"sign_unplace", 1, 2, FEARG_1, arg2_string_dict, ret_number_bool, SIGN_FUNC(f_sign_unplace)}, ! {"sign_unplacelist", 1, 2, FEARG_1, arg1_list_any, ret_list_number, SIGN_FUNC(f_sign_unplacelist)}, {"simplify", 1, 1, FEARG_1, arg1_string, ret_string, f_simplify}, *************** *** 1630,1644 **** ret_list_number, f_str2list}, {"str2nr", 1, 3, FEARG_1, arg3_string_nr_bool, ret_number, f_str2nr}, ! {"strcharlen", 1, 1, FEARG_1, NULL, ret_number, f_strcharlen}, {"strcharpart", 2, 4, FEARG_1, NULL, ret_string, f_strcharpart}, {"strchars", 1, 2, FEARG_1, NULL, ret_number, f_strchars}, ! {"strdisplaywidth", 1, 2, FEARG_1, NULL, ret_number, f_strdisplaywidth}, ! {"strftime", 1, 2, FEARG_1, NULL, ret_string, #ifdef HAVE_STRFTIME f_strftime --- 1655,1669 ---- ret_list_number, f_str2list}, {"str2nr", 1, 3, FEARG_1, arg3_string_nr_bool, ret_number, f_str2nr}, ! {"strcharlen", 1, 1, FEARG_1, arg1_string_or_nr, ret_number, f_strcharlen}, {"strcharpart", 2, 4, FEARG_1, NULL, ret_string, f_strcharpart}, {"strchars", 1, 2, FEARG_1, NULL, ret_number, f_strchars}, ! {"strdisplaywidth", 1, 2, FEARG_1, arg2_string_nr, ret_number, f_strdisplaywidth}, ! {"strftime", 1, 2, FEARG_1, arg2_string_nr, ret_string, #ifdef HAVE_STRFTIME f_strftime *************** *** 1646,1652 **** NULL #endif }, ! {"strgetchar", 2, 2, FEARG_1, NULL, ret_number, f_strgetchar}, {"stridx", 2, 3, FEARG_1, arg3_string_string_nr, ret_number, f_stridx}, --- 1671,1677 ---- NULL #endif }, ! {"strgetchar", 2, 2, FEARG_1, arg2_string_nr, ret_number, f_strgetchar}, {"stridx", 2, 3, FEARG_1, arg3_string_string_nr, ret_number, f_stridx}, *************** *** 1696,1702 **** ret_list_number, f_tabpagebuflist}, {"tabpagenr", 0, 1, 0, arg1_string, ret_number, f_tabpagenr}, ! {"tabpagewinnr", 1, 2, FEARG_1, NULL, ret_number, f_tabpagewinnr}, {"tagfiles", 0, 0, 0, NULL, ret_list_string, f_tagfiles}, --- 1721,1727 ---- ret_list_number, f_tabpagebuflist}, {"tabpagenr", 0, 1, 0, arg1_string, ret_number, f_tabpagenr}, ! {"tabpagewinnr", 1, 2, FEARG_1, arg2_nr_string, ret_number, f_tabpagewinnr}, {"tagfiles", 0, 0, 0, NULL, ret_list_string, f_tagfiles}, *************** *** 1724,1730 **** NULL #endif }, ! {"term_getattr", 2, 2, FEARG_1, NULL, ret_number, TERM_FUNC(f_term_getattr)}, {"term_getcursor", 1, 1, FEARG_1, arg1_string_or_nr, ret_list_any, TERM_FUNC(f_term_getcursor)}, --- 1749,1755 ---- NULL #endif }, ! {"term_getattr", 2, 2, FEARG_1, arg2_nr_string, ret_number, TERM_FUNC(f_term_getattr)}, {"term_getcursor", 1, 1, FEARG_1, arg1_string_or_nr, ret_list_any, TERM_FUNC(f_term_getcursor)}, *************** *** 1806,1812 **** ret_string, f_test_null_string}, {"test_option_not_set", 1, 1, FEARG_1, arg1_string, ret_void, f_test_option_not_set}, ! {"test_override", 2, 2, FEARG_2, NULL, ret_void, f_test_override}, {"test_refcount", 1, 1, FEARG_1, NULL, ret_number, f_test_refcount}, --- 1831,1837 ---- ret_string, f_test_null_string}, {"test_option_not_set", 1, 1, FEARG_1, arg1_string, ret_void, f_test_option_not_set}, ! {"test_override", 2, 2, FEARG_2, arg2_string_nr, ret_void, f_test_override}, {"test_refcount", 1, 1, FEARG_1, NULL, ret_number, f_test_refcount}, *************** *** 1858,1868 **** ret_dict_any, f_undotree}, {"uniq", 1, 3, FEARG_1, NULL, ret_list_any, f_uniq}, ! {"values", 1, 1, FEARG_1, arg1_dict, ret_list_any, f_values}, {"virtcol", 1, 1, FEARG_1, arg1_string_or_list_any, ret_number, f_virtcol}, ! {"visualmode", 0, 1, 0, NULL, ret_string, f_visualmode}, {"wildmenumode", 0, 0, 0, NULL, ret_number, f_wildmenumode}, --- 1883,1893 ---- ret_dict_any, f_undotree}, {"uniq", 1, 3, FEARG_1, NULL, ret_list_any, f_uniq}, ! {"values", 1, 1, FEARG_1, arg1_dict_any, ret_list_any, f_values}, {"virtcol", 1, 1, FEARG_1, arg1_string_or_list_any, ret_number, f_virtcol}, ! {"visualmode", 0, 1, 0, arg1_bool, ret_string, f_visualmode}, {"wildmenumode", 0, 0, 0, NULL, ret_number, f_wildmenumode}, *************** *** 1900,1906 **** ret_number, f_winnr}, {"winrestcmd", 0, 0, 0, NULL, ret_string, f_winrestcmd}, ! {"winrestview", 1, 1, FEARG_1, arg1_dict, ret_void, f_winrestview}, {"winsaveview", 0, 0, 0, NULL, ret_dict_number, f_winsaveview}, --- 1925,1931 ---- ret_number, f_winnr}, {"winrestcmd", 0, 0, 0, NULL, ret_string, f_winrestcmd}, ! {"winrestview", 1, 1, FEARG_1, arg1_dict_any, ret_void, f_winrestview}, {"winsaveview", 0, 0, 0, NULL, ret_dict_number, f_winsaveview}, *************** *** 2763,2770 **** static void f_echoraw(typval_T *argvars, typval_T *rettv UNUSED) { ! char_u *str = tv_get_string_chk(&argvars[0]); if (str != NULL && *str != NUL) { out_str(str); --- 2788,2799 ---- static void f_echoraw(typval_T *argvars, typval_T *rettv UNUSED) { ! char_u *str; ! ! if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) ! return; + str = tv_get_string_chk(&argvars[0]); if (str != NULL && *str != NUL) { out_str(str); *************** *** 5956,5961 **** --- 5985,5994 ---- dictitem_T *di; rettv->vval.v_number = -1; + + if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + return; + end = get_lval(tv_get_string(&argvars[0]), NULL, &lv, FALSE, FALSE, GLV_NO_AUTOLOAD | GLV_READ_ONLY, FNE_CHECK_START); if (end != NULL && lv.ll_name != NULL) *************** *** 6122,6127 **** --- 6155,6166 ---- win_T *save_curwin; tabpage_T *save_curtab; + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || (argvars[1].v_type != VAR_UNKNOWN + && check_for_number_arg(argvars, 1) == FAIL))) + return; + if (argvars[1].v_type != VAR_UNKNOWN) { // use window specified in the second argument *** ../vim-8.2.3161/src/evalwindow.c 2021-06-27 22:03:28.641707728 +0200 --- src/evalwindow.c 2021-07-15 10:53:45.238392517 +0200 *************** *** 653,658 **** --- 653,664 ---- int nr = 1; tabpage_T *tp; + if (in_vim9script() + && (check_for_number_arg(argvars, 0) == FAIL + || (argvars[1].v_type != VAR_UNKNOWN + && check_for_string_arg(argvars, 1) == FAIL))) + return; + tp = find_tabpage((int)tv_get_number(&argvars[0])); if (tp == NULL) nr = 0; *** ../vim-8.2.3161/src/filepath.c 2021-06-27 22:03:28.641707728 +0200 --- src/filepath.c 2021-07-15 10:53:45.238392517 +0200 *************** *** 1447,1452 **** --- 1447,1458 ---- char_u *p; int trim_len = 1; + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || (argvars[1].v_type != VAR_UNKNOWN + && check_for_number_arg(argvars, 1) == FAIL))) + return; + if (argvars[1].v_type != VAR_UNKNOWN) { trim_len = (int)tv_get_number(&argvars[1]); *** ../vim-8.2.3161/src/globals.h 2021-07-07 21:21:27.117414087 +0200 --- src/globals.h 2021-07-15 10:53:45.238392517 +0200 *************** *** 1698,1703 **** --- 1698,1704 ---- EXTERN char e_readonlyvar[] INIT(= N_("E46: Cannot change read-only variable \"%s\"")); EXTERN char e_readonlysbx[] INIT(= N_("E794: Cannot set variable in the sandbox: \"%s\"")); EXTERN char e_stringreq[] INIT(= N_("E928: String required")); + EXTERN char e_numberreq[] INIT(= N_("E889: Number required")); EXTERN char e_emptykey[] INIT(= N_("E713: Cannot use empty key for Dictionary")); EXTERN char e_dictreq[] INIT(= N_("E715: Dictionary required")); EXTERN char e_listidx[] INIT(= N_("E684: list index out of range: %ld")); *** ../vim-8.2.3161/src/popupwin.c 2021-06-27 22:03:28.645707721 +0200 --- src/popupwin.c 2021-07-15 10:53:45.238392517 +0200 *************** *** 2359,2371 **** void f_popup_filter_menu(typval_T *argvars, typval_T *rettv) { ! int id = tv_get_number(&argvars[0]); ! win_T *wp = win_id2wp(id); ! char_u *key = tv_get_string(&argvars[1]); typval_T res; int c; linenr_T old_lnum; // If the popup has been closed do not consume the key. if (wp == NULL) return; --- 2359,2379 ---- void f_popup_filter_menu(typval_T *argvars, typval_T *rettv) { ! int id; ! win_T *wp; ! char_u *key; typval_T res; int c; linenr_T old_lnum; + if (in_vim9script() + && (check_for_number_arg(argvars, 0) == FAIL + || check_for_string_arg(argvars, 1) == FAIL)) + return; + + id = tv_get_number(&argvars[0]); + wp = win_id2wp(id); + key = tv_get_string(&argvars[1]); // If the popup has been closed do not consume the key. if (wp == NULL) return; *************** *** 2416,2427 **** void f_popup_filter_yesno(typval_T *argvars, typval_T *rettv) { ! int id = tv_get_number(&argvars[0]); ! win_T *wp = win_id2wp(id); ! char_u *key = tv_get_string(&argvars[1]); typval_T res; int c; // If the popup has been closed don't consume the key. if (wp == NULL) return; --- 2424,2443 ---- void f_popup_filter_yesno(typval_T *argvars, typval_T *rettv) { ! int id; ! win_T *wp; ! char_u *key; typval_T res; int c; + if (in_vim9script() + && (check_for_number_arg(argvars, 0) == FAIL + || check_for_string_arg(argvars, 1) == FAIL)) + return; + + id = tv_get_number(&argvars[0]); + wp = win_id2wp(id); + key = tv_get_string(&argvars[1]); // If the popup has been closed don't consume the key. if (wp == NULL) return; *************** *** 2727,2735 **** f_popup_move(typval_T *argvars, typval_T *rettv UNUSED) { dict_T *dict; ! int id = (int)tv_get_number(argvars); ! win_T *wp = find_popup_win(id); if (wp == NULL) return; // invalid {id} --- 2743,2758 ---- f_popup_move(typval_T *argvars, typval_T *rettv UNUSED) { dict_T *dict; ! int id; ! win_T *wp; + if (in_vim9script() + && (check_for_number_arg(argvars, 0) == FAIL + || check_for_dict_arg(argvars, 1) == FAIL)) + return; + + id = (int)tv_get_number(argvars); + wp = find_popup_win(id); if (wp == NULL) return; // invalid {id} *************** *** 2754,2763 **** f_popup_setoptions(typval_T *argvars, typval_T *rettv UNUSED) { dict_T *dict; ! int id = (int)tv_get_number(argvars); ! win_T *wp = find_popup_win(id); linenr_T old_firstline; if (wp == NULL) return; // invalid {id} --- 2777,2793 ---- f_popup_setoptions(typval_T *argvars, typval_T *rettv UNUSED) { dict_T *dict; ! int id; ! win_T *wp; linenr_T old_firstline; + if (in_vim9script() + && (check_for_number_arg(argvars, 0) == FAIL + || check_for_dict_arg(argvars, 1) == FAIL)) + return; + + id = (int)tv_get_number(argvars); + wp = find_popup_win(id); if (wp == NULL) return; // invalid {id} *** ../vim-8.2.3161/src/proto/typval.pro 2021-07-10 13:15:35.291053015 +0200 --- src/proto/typval.pro 2021-07-15 10:53:45.238392517 +0200 *************** *** 11,16 **** --- 11,17 ---- float_T tv_get_float(typval_T *varp); int check_for_string_arg(typval_T *args, int idx); int check_for_nonempty_string_arg(typval_T *args, int idx); + int check_for_number_arg(typval_T *args, int idx); int check_for_dict_arg(typval_T *args, int idx); char_u *tv_get_string(typval_T *varp); char_u *tv_get_string_strict(typval_T *varp); *** ../vim-8.2.3161/src/sign.c 2020-08-31 23:17:57.503559788 +0200 --- src/sign.c 2021-07-15 10:53:45.238392517 +0200 *************** *** 2274,2280 **** --- 2274,2284 ---- return; if (argvars[0].v_type != VAR_UNKNOWN) + { + if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + return; name = tv_get_string(&argvars[0]); + } sign_getlist(name, rettv->vval.v_list); } *** ../vim-8.2.3161/src/strings.c 2021-07-10 21:28:55.331050104 +0200 --- src/strings.c 2021-07-15 10:53:45.238392517 +0200 *************** *** 795,803 **** char_u *str; varnumber_T idx; str = tv_get_string_chk(&argvars[0]); idx = tv_get_number_chk(&argvars[1], NULL); - rettv->vval.v_number = -1; if (str == NULL || idx < 0) return; --- 795,809 ---- char_u *str; varnumber_T idx; + rettv->vval.v_number = -1; + + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || check_for_number_arg(argvars, 1) == FAIL)) + return; + str = tv_get_string_chk(&argvars[0]); idx = tv_get_number_chk(&argvars[1], NULL); if (str == NULL || idx < 0) return; *************** *** 981,986 **** --- 987,998 ---- int byteidx = 0; rettv->vval.v_number = -1; + + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || check_for_number_arg(argvars, 1) == FAIL)) + return; + str = tv_get_string_chk(&argvars[0]); if (str == NULL) return; *************** *** 1110,1118 **** void f_strdisplaywidth(typval_T *argvars, typval_T *rettv) { ! char_u *s = tv_get_string(&argvars[0]); int col = 0; if (argvars[1].v_type != VAR_UNKNOWN) col = (int)tv_get_number(&argvars[1]); --- 1122,1139 ---- void f_strdisplaywidth(typval_T *argvars, typval_T *rettv) { ! char_u *s; int col = 0; + rettv->vval.v_number = -1; + + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || (argvars[1].v_type != VAR_UNKNOWN + && check_for_number_arg(argvars, 1) == FAIL))) + return; + + s = tv_get_string(&argvars[0]); if (argvars[1].v_type != VAR_UNKNOWN) col = (int)tv_get_number(&argvars[1]); *** ../vim-8.2.3161/src/terminal.c 2021-07-10 13:15:35.295053013 +0200 --- src/terminal.c 2021-07-15 10:53:45.238392517 +0200 *************** *** 5689,5694 **** --- 5689,5699 ---- {"reverse", HL_INVERSE}, }; + if (in_vim9script() + && (check_for_number_arg(argvars, 0) == FAIL + || check_for_string_arg(argvars, 1) == FAIL)) + return; + attr = tv_get_number(&argvars[0]); name = tv_get_string_chk(&argvars[1]); if (name == NULL) *** ../vim-8.2.3161/src/testdir/test_normal.vim 2021-05-31 19:22:58.583454940 +0200 --- src/testdir/test_normal.vim 2021-07-15 10:53:45.242392507 +0200 *************** *** 2614,2620 **** set noim call assert_equal('are some words', getline(1)) call assert_false(&insertmode) ! call assert_beeps("normal! \\", 'xt') if has('cmdwin') " Using CTRL-\ CTRL-N in cmd window should close the window --- 2614,2620 ---- set noim call assert_equal('are some words', getline(1)) call assert_false(&insertmode) ! call assert_beeps("normal! \\") if has('cmdwin') " Using CTRL-\ CTRL-N in cmd window should close the window *** ../vim-8.2.3161/src/testdir/test_reltime.vim 2020-04-26 15:59:51.206952132 +0200 --- src/testdir/test_reltime.vim 2021-07-15 10:53:45.242392507 +0200 *************** *** 24,31 **** call assert_true(reltimefloat(differs) < 0.1) call assert_true(reltimefloat(differs) > 0.0) ! call assert_equal(0, reltime({})) ! call assert_equal(0, reltime({}, {})) endfunc " vim: shiftwidth=2 sts=2 expandtab --- 24,31 ---- call assert_true(reltimefloat(differs) < 0.1) call assert_true(reltimefloat(differs) > 0.0) ! call assert_equal([], reltime({})) ! call assert_equal([], reltime({}, {})) endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3161/src/testdir/test_vim9_builtin.vim 2021-07-14 21:00:38.065084719 +0200 --- src/testdir/test_vim9_builtin.vim 2021-07-15 10:53:45.242392507 +0200 *************** *** 75,80 **** --- 75,115 ---- endif enddef + def Test_add_blob() + var b1: blob = 0z12 + add(b1, 0x34) + assert_equal(0z1234, b1) + + var b2: blob # defaults to empty blob + add(b2, 0x67) + assert_equal(0z67, b2) + + var lines =<< trim END + var b: blob + add(b, "x") + END + CheckDefFailure(lines, 'E1012:', 2) + + lines =<< trim END + add(test_null_blob(), 123) + END + CheckDefExecAndScriptFailure(lines, 'E1131:', 1) + + lines =<< trim END + var b: blob = test_null_blob() + add(b, 123) + END + CheckDefExecFailure(lines, 'E1131:', 2) + + # Getting variable with NULL blob allocates a new blob at script level + lines =<< trim END + vim9script + var b: blob = test_null_blob() + add(b, 123) + END + CheckScriptSuccess(lines) + enddef + def Test_add_list() var l: list # defaults to empty list add(l, 9) *************** *** 120,160 **** CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3) enddef - def Test_add_blob() - var b1: blob = 0z12 - add(b1, 0x34) - assert_equal(0z1234, b1) - - var b2: blob # defaults to empty blob - add(b2, 0x67) - assert_equal(0z67, b2) - - var lines =<< trim END - var b: blob - add(b, "x") - END - CheckDefFailure(lines, 'E1012:', 2) - - lines =<< trim END - add(test_null_blob(), 123) - END - CheckDefExecAndScriptFailure(lines, 'E1131:', 1) - - lines =<< trim END - var b: blob = test_null_blob() - add(b, 123) - END - CheckDefExecFailure(lines, 'E1131:', 2) - - # Getting variable with NULL blob allocates a new blob at script level - lines =<< trim END - vim9script - var b: blob = test_null_blob() - add(b, 123) - END - CheckScriptSuccess(lines) - enddef - def Test_and() CheckDefAndScriptFailure2(['and("x", 0x2)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') CheckDefAndScriptFailure2(['and(0x1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1030: Using a String as a Number') --- 155,160 ---- *************** *** 171,176 **** --- 171,200 ---- append(0, 'zero') assert_equal('zero', getline(1)) + append(0, {a: 10}) + assert_equal("{'a': 10}", getline(1)) + append(0, function('min')) + assert_equal("function('min')", getline(1)) + CheckDefAndScriptFailure2(['append([1], "x")'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E745: Using a List as a Number') + bwipe! + enddef + + def Test_appendbufline() + new + var bnum: number = bufnr() + :wincmd w + appendbufline(bnum, 0, range(3)) + var res1: number = appendbufline(bnum, 1, 'one') + assert_equal(0, res1) + var res2: bool = appendbufline(bnum, 3, 'two') + assert_equal(false, res2) + assert_equal(['0', 'one', '1', 'two', '2', ''], getbufline(bnum, 1, '$')) + appendbufline(bnum, 0, 'zero') + assert_equal(['zero'], getbufline(bnum, 1)) + CheckDefFailure(['appendbufline([1], 1, "x")'], 'E1013: Argument 1: type mismatch, expected string but got list') + CheckDefFailure(['appendbufline(1, [1], "x")'], 'E1013: Argument 2: type mismatch, expected string but got list') + CheckDefFailure(['appendbufline(1, 1, {"a": 10})'], 'E1013: Argument 3: type mismatch, expected string but got dict') + bnum->bufwinid()->win_gotoid() bwipe! enddef *************** *** 190,195 **** --- 214,223 ---- CheckDefFailure(['argv("x", "y")'], 'E1013: Argument 1: type mismatch, expected number but got string') enddef + def Test_assert_beeps() + CheckDefAndScriptFailure2(['assert_beeps(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + enddef + def Test_assert_equalfile() CheckDefFailure(['assert_equalfile(1, "f2")'], 'E1013: Argument 1: type mismatch, expected string but got number') CheckDefFailure(['assert_equalfile("f1", true)'], 'E1013: Argument 2: type mismatch, expected string but got bool') *************** *** 207,212 **** --- 235,244 ---- CheckDefFailure(['assert_match("a", "b", null)'], 'E1013: Argument 3: type mismatch, expected string but got special') enddef + def Test_assert_nobeep() + CheckDefAndScriptFailure2(['assert_nobeep(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + enddef + def Test_assert_notmatch() CheckDefFailure(['assert_notmatch({}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict') CheckDefFailure(['assert_notmatch("a", 1)'], 'E1013: Argument 2: type mismatch, expected string but got number') *************** *** 328,333 **** --- 360,375 ---- assert_equal(-1, byte2line(0)) enddef + def Test_byteidx() + CheckDefAndScriptFailure2(['byteidx(1, 2)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['byteidx("a", "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + + def Test_byteidxcomp() + CheckDefAndScriptFailure2(['byteidxcomp(1, 2)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['byteidxcomp("a", "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + def Test_call_call() var l = [3, 2, 1] call('reverse', [l]) *************** *** 355,360 **** --- 397,408 ---- CheckDefFailure(['ch_close_in(true)'], 'E1013: Argument 1: type mismatch, expected channel but got bool') enddef + def Test_ch_getjob() + CheckDefAndScriptFailure2(['ch_getjob(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument:') + CheckDefAndScriptFailure2(['ch_getjob({"a": 10})'], 'E1013: Argument 1: type mismatch, expected channel but got dict', 'E731: Using a Dictionary as a String') + assert_equal(0, ch_getjob(test_null_channel())) + enddef + def Test_ch_info() if !has('channel') CheckFeature channel *************** *** 381,386 **** --- 429,474 ---- CheckDefAndScriptFailure2(['ch_open("a", [1])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2') enddef + def Test_ch_read() + if !has('channel') + CheckFeature channel + endif + CheckDefAndScriptFailure2(['ch_read(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument') + CheckDefAndScriptFailure2(['ch_read(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') + enddef + + def Test_ch_readblob() + if !has('channel') + CheckFeature channel + endif + CheckDefAndScriptFailure2(['ch_readblob(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument') + CheckDefAndScriptFailure2(['ch_readblob(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') + enddef + + def Test_ch_readraw() + if !has('channel') + CheckFeature channel + endif + CheckDefAndScriptFailure2(['ch_readraw(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument') + CheckDefAndScriptFailure2(['ch_readraw(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') + enddef + + def Test_ch_setoptions() + if !has('channel') + CheckFeature channel + endif + CheckDefAndScriptFailure2(['ch_setoptions(1, {})'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument') + CheckDefFailure(['ch_setoptions(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict but got list') + enddef + + def Test_ch_status() + if !has('channel') + CheckFeature channel + endif + CheckDefAndScriptFailure2(['ch_status(1)'], 'E1013: Argument 1: type mismatch, expected channel but got number', 'E475: Invalid argument') + CheckDefAndScriptFailure2(['ch_status(test_null_channel(), [])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') + enddef + def Test_char2nr() char2nr('あ', true)->assert_equal(12354) *************** *** 440,445 **** --- 528,540 ---- bw! enddef + def Test_complete_info() + CheckDefFailure(['complete_info("")'], 'E1013: Argument 1: type mismatch, expected list but got string') + CheckDefFailure(['complete_info({})'], 'E1013: Argument 1: type mismatch, expected list but got dict') + assert_equal({'pum_visible': 0, 'mode': '', 'selected': -1, 'items': []}, complete_info()) + assert_equal({'mode': '', 'items': []}, complete_info(['mode', 'items'])) + enddef + def Test_confirm() if !has('dialog_con') && !has('dialog_gui') CheckFeature dialog_con *************** *** 450,462 **** assert_fails('confirm("yes", "maybe", 2, true)', 'E1174:') enddef - def Test_complete_info() - CheckDefFailure(['complete_info("")'], 'E1013: Argument 1: type mismatch, expected list but got string') - CheckDefFailure(['complete_info({})'], 'E1013: Argument 1: type mismatch, expected list but got dict') - assert_equal({'pum_visible': 0, 'mode': '', 'selected': -1, 'items': []}, complete_info()) - assert_equal({'mode': '', 'items': []}, complete_info(['mode', 'items'])) - enddef - def Test_copy_return_type() var l = copy([1, 2, 3]) var res = 0 --- 545,550 ---- *************** *** 514,519 **** --- 602,612 ---- assert_equal(0, diff_filler('.')) enddef + def Test_echoraw() + CheckDefAndScriptFailure2(['echoraw(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['echoraw(["x"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1') + enddef + def Test_escape() CheckDefFailure(['escape("a", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number') CheckDefFailure(['escape(10, " ")'], 'E1013: Argument 1: type mismatch, expected string but got number') *************** *** 604,628 **** CheckDefExecFailure(['extend([1], ["b", 1])'], 'E1013: Argument 2: type mismatch, expected list but got list') enddef - def Test_extendnew() - assert_equal([1, 2, 'a'], extendnew([1, 2], ['a'])) - assert_equal({one: 1, two: 'a'}, extendnew({one: 1}, {two: 'a'})) - - CheckDefFailure(['extendnew({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict but got number') - CheckDefFailure(['extendnew({a: 1}, [42])'], 'E1013: Argument 2: type mismatch, expected dict but got list') - CheckDefFailure(['extendnew([1, 2], "x")'], 'E1013: Argument 2: type mismatch, expected list but got string') - CheckDefFailure(['extendnew([1, 2], {x: 1})'], 'E1013: Argument 2: type mismatch, expected list but got dict') - enddef - - def Test_extend_return_type() - var l = extend([1, 2], [3]) - var res = 0 - for n in l - res += n - endfor - res->assert_equal(6) - enddef - func g:ExtendDict(d) call extend(a:d, #{xx: 'x'}) endfunc --- 697,702 ---- *************** *** 673,678 **** --- 747,761 ---- CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) enddef + def Test_extend_return_type() + var l = extend([1, 2], [3]) + var res = 0 + for n in l + res += n + endfor + res->assert_equal(6) + enddef + def Test_extend_with_error_function() var lines =<< trim END vim9script *************** *** 693,698 **** --- 776,791 ---- CheckScriptFailure(lines, 'E1001: Variable not found: m') enddef + def Test_extendnew() + assert_equal([1, 2, 'a'], extendnew([1, 2], ['a'])) + assert_equal({one: 1, two: 'a'}, extendnew({one: 1}, {two: 'a'})) + + CheckDefFailure(['extendnew({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict but got number') + CheckDefFailure(['extendnew({a: 1}, [42])'], 'E1013: Argument 2: type mismatch, expected dict but got list') + CheckDefFailure(['extendnew([1, 2], "x")'], 'E1013: Argument 2: type mismatch, expected list but got string') + CheckDefFailure(['extendnew([1, 2], {x: 1})'], 'E1013: Argument 2: type mismatch, expected list but got dict') + enddef + def Test_feedkeys() CheckDefFailure(['feedkeys(10)'], 'E1013: Argument 1: type mismatch, expected string but got number') CheckDefFailure(['feedkeys("x", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number') *************** *** 703,738 **** unlet g:TestVar enddef - def Test_indent() - CheckDefAndScriptFailure2(['indent([1])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E745: Using a List as a Number') - CheckDefAndScriptFailure2(['indent(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1138: Using a Bool as a Number') - assert_equal(0, indent(1)) - enddef - - def Test_input() - CheckDefFailure(['input(5)'], 'E1013: Argument 1: type mismatch, expected string but got number') - CheckDefAndScriptFailure2(['input(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') - CheckDefFailure(['input("p", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number') - CheckDefAndScriptFailure2(['input("p", "q", 20)'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E180: Invalid complete value') - enddef - - def Test_inputdialog() - CheckDefFailure(['inputdialog(5)'], 'E1013: Argument 1: type mismatch, expected string but got number') - CheckDefAndScriptFailure2(['inputdialog(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') - CheckDefFailure(['inputdialog("p", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number') - CheckDefFailure(['inputdialog("p", "q", 20)'], 'E1013: Argument 3: type mismatch, expected string but got number') - enddef - - def Test_job_info_return_type() - if has('job') - job_start(&shell) - var jobs = job_info() - assert_equal('list', typename(jobs)) - assert_equal('dict', typename(job_info(jobs[0]))) - job_stop(jobs[0]) - endif - enddef - def Test_filereadable() assert_false(filereadable("")) assert_false(filereadable(test_null_string())) --- 796,801 ---- *************** *** 928,933 **** --- 991,998 ---- def Test_garbagecollect() garbagecollect(true) + CheckDefAndScriptFailure2(['garbagecollect("1")'], 'E1013: Argument 1: type mismatch, expected bool but got string', 'E1135: Using a String as a Bool') + CheckDefAndScriptFailure2(['garbagecollect(20)'], 'E1013: Argument 1: type mismatch, expected bool but got number', 'E1023: Using a Number as a Bool') enddef def Test_getbufinfo() *************** *** 967,972 **** --- 1032,1050 ---- while getchar(0) endwhile getchar(true)->assert_equal(0) + getchar(1)->assert_equal(0) + CheckDefAndScriptFailure2(['getchar(2)'], 'E1013: Argument 1: type mismatch, expected bool but got number', 'E1023: Using a Number as a Bool') + CheckDefAndScriptFailure2(['getchar("1")'], 'E1013: Argument 1: type mismatch, expected bool but got string', 'E1135: Using a String as a Bool') + enddef + + def Test_getcharpos() + CheckDefAndScriptFailure2(['getcharpos(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['getcharpos(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + enddef + + def Test_getcharstr() + CheckDefAndScriptFailure2(['getcharstr(2)'], 'E1013: Argument 1: type mismatch, expected bool but got number', 'E1023: Using a Number as a Bool') + CheckDefAndScriptFailure2(['getcharstr("1")'], 'E1013: Argument 1: type mismatch, expected bool but got string', 'E1135: Using a String as a Bool') enddef def Test_getenv() *************** *** 1003,1016 **** CheckDefFailure(['getcwd(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string') enddef - def Test_getloclist_return_type() - var l = getloclist(1) - l->assert_equal([]) - - var d = getloclist(1, {items: 0}) - d->assert_equal({items: []}) - enddef - def Test_getfontname() CheckDefFailure(['getfontname(10)'], 'E1013: Argument 1: type mismatch, expected string but got number') enddef --- 1081,1086 ---- *************** *** 1072,1077 **** --- 1142,1160 ---- CheckDefExecAndScriptFailure(lines, 'E1209:') enddef + def Test_getloclist() + CheckDefAndScriptFailure2(['getloclist("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + CheckDefAndScriptFailure2(['getloclist(1, [])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') + enddef + + def Test_getloclist_return_type() + var l = getloclist(1) + l->assert_equal([]) + + var d = getloclist(1, {items: 0}) + d->assert_equal({items: []}) + enddef + def Test_getmarklist() CheckDefFailure(['getmarklist([])'], 'E1013: Argument 1: type mismatch, expected string but got list') assert_equal([], getmarklist(10000)) *************** *** 1197,1202 **** --- 1280,1290 ---- assert_equal('skyblue', histget('/', -1)) enddef + def Test_histget() + CheckDefAndScriptFailure2(['histget(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['histget("a", "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + def Test_histnr() CheckDefFailure(['histnr(10)'], 'E1013: Argument 1: type mismatch, expected string but got number') assert_equal(-1, histnr('abc')) *************** *** 1219,1228 **** --- 1307,1336 ---- assert_equal('abc', iconv('abc', 'fromenc', 'toenc')) enddef + def Test_indent() + CheckDefAndScriptFailure2(['indent([1])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E745: Using a List as a Number') + CheckDefAndScriptFailure2(['indent(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1138: Using a Bool as a Number') + assert_equal(0, indent(1)) + enddef + def Test_index() index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3) enddef + def Test_input() + CheckDefFailure(['input(5)'], 'E1013: Argument 1: type mismatch, expected string but got number') + CheckDefAndScriptFailure2(['input(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + CheckDefFailure(['input("p", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number') + CheckDefAndScriptFailure2(['input("p", "q", 20)'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E180: Invalid complete value') + enddef + + def Test_inputdialog() + CheckDefFailure(['inputdialog(5)'], 'E1013: Argument 1: type mismatch, expected string but got number') + CheckDefAndScriptFailure2(['inputdialog(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + CheckDefFailure(['inputdialog("p", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number') + CheckDefFailure(['inputdialog("p", "q", 20)'], 'E1013: Argument 3: type mismatch, expected string but got number') + enddef + def Test_inputlist() CheckDefFailure(['inputlist(10)'], 'E1013: Argument 1: type mismatch, expected list but got number') CheckDefFailure(['inputlist("abc")'], 'E1013: Argument 1: type mismatch, expected list but got string') *************** *** 1289,1300 **** --- 1397,1443 ---- assert_false(isdirectory('NonExistingDir')) enddef + def Test_islocked() + CheckDefAndScriptFailure2(['islocked(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['var n1: number = 10', 'islocked(n1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + g:v1 = 10 + assert_false(islocked('g:v1')) + lockvar g:v1 + assert_true(islocked('g:v1')) + unlet g:v1 + enddef + def Test_items() CheckDefFailure(['[]->items()'], 'E1013: Argument 1: type mismatch, expected dict but got list') assert_equal([['a', 10], ['b', 20]], {'a': 10, 'b': 20}->items()) assert_equal([], {}->items()) enddef + def Test_job_getchannel() + CheckDefAndScriptFailure2(['job_getchannel("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') + assert_fails('job_getchannel(test_null_job())', 'E916: not a valid job') + enddef + + def Test_job_info() + CheckDefAndScriptFailure2(['job_info("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') + assert_fails('job_info(test_null_job())', 'E916: not a valid job') + enddef + + def Test_job_info_return_type() + if has('job') + job_start(&shell) + var jobs = job_info() + assert_equal('list', typename(jobs)) + assert_equal('dict', typename(job_info(jobs[0]))) + job_stop(jobs[0]) + endif + enddef + + def Test_job_status() + CheckDefAndScriptFailure2(['job_status("a")'], 'E1013: Argument 1: type mismatch, expected job but got string', 'E475: Invalid argument') + assert_equal('fail', job_status(test_null_job())) + enddef + def Test_js_decode() CheckDefFailure(['js_decode(10)'], 'E1013: Argument 1: type mismatch, expected string but got number') assert_equal([1, 2], js_decode('[1,2]')) *************** *** 1318,1323 **** --- 1461,1468 ---- def Test_line() assert_fails('line(true)', 'E1174:') + CheckDefAndScriptFailure2(['line(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['line(".", "a")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') enddef def Test_line2byte() *************** *** 1476,1481 **** --- 1621,1627 ---- ? [1, max([2, 3])] : [4, 5] assert_equal([4, 5], l2) + CheckDefAndScriptFailure2(['max(5)'], 'E1013: Argument 1: type mismatch, expected list but got number', 'E712: Argument of max() must be a List or Dictionary') enddef def Test_menu_info() *************** *** 1497,1502 **** --- 1643,1649 ---- ? [1, min([2, 3])] : [4, 5] assert_equal([4, 5], l2) + CheckDefAndScriptFailure2(['min(5)'], 'E1013: Argument 1: type mismatch, expected list but got number', 'E712: Argument of min() must be a List or Dictionary') enddef def Test_mkdir() *************** *** 1506,1511 **** --- 1653,1670 ---- delete('a', 'rf') enddef + def Test_mode() + CheckDefFailure(['mode("1")'], 'E1013: Argument 1: type mismatch, expected bool but got string') + CheckDefFailure(['mode(2)'], 'E1013: Argument 1: type mismatch, expected bool but got number') + enddef + + def Test_mzeval() + if !has('mzscheme') + CheckFeature mzscheme + endif + CheckDefAndScriptFailure2(['mzscheme(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + enddef + def Test_nextnonblank() CheckDefFailure(['nextnonblank(null)'], 'E1013: Argument 1: type mismatch, expected string but got special') assert_equal(0, nextnonblank(1)) *************** *** 1520,1525 **** --- 1679,1696 ---- CheckDefFailure(['or(0x1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string') enddef + def Test_pathshorten() + CheckDefAndScriptFailure2(['pathshorten(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['pathshorten("a", "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + + def Test_perleval() + if !has('perl') + CheckFeature perl + endif + CheckDefAndScriptFailure2(['perleval(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + enddef + def Test_popup_atcursor() CheckDefAndScriptFailure2(['popup_atcursor({"a": 10}, {})'], 'E1013: Argument 1: type mismatch, expected string but got dict', 'E450: buffer number, text or a list required') CheckDefAndScriptFailure2(['popup_atcursor("a", [1, 2])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') *************** *** 1536,1541 **** --- 1707,1717 ---- CheckDefAndScriptFailure2(['popup_beval("a", [1, 2])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') enddef + def Test_popup_clear() + CheckDefAndScriptFailure2(['popup_clear(["a"])'], 'E1013: Argument 1: type mismatch, expected bool but got list', 'E745: Using a List as a Number') + CheckDefAndScriptFailure2(['popup_clear(2)'], 'E1013: Argument 1: type mismatch, expected bool but got number', 'E1023: Using a Number as a Bool') + enddef + def Test_popup_create() # Pass variable of type 'any' to popup_create() var what: any = 'Hello' *************** *** 1549,1554 **** --- 1725,1755 ---- CheckDefAndScriptFailure2(['popup_dialog("a", [1, 2])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') enddef + def Test_popup_filter_menu() + CheckDefAndScriptFailure2(['popup_filter_menu("x", "")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1') + CheckDefAndScriptFailure2(['popup_filter_menu(1, 1)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2') + enddef + + def Test_popup_filter_yesno() + CheckDefAndScriptFailure2(['popup_filter_yesno("x", "")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1') + CheckDefAndScriptFailure2(['popup_filter_yesno(1, 1)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2') + enddef + + def Test_popup_getoptions() + CheckDefAndScriptFailure2(['popup_getoptions("a")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + CheckDefAndScriptFailure2(['popup_getoptions(true)'], 'E1013: Argument 1: type mismatch, expected number but got bool', 'E1138: Using a Bool as a Number') + enddef + + def Test_popup_getpos() + CheckDefAndScriptFailure2(['popup_getpos("a")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + CheckDefAndScriptFailure2(['popup_getpos(true)'], 'E1013: Argument 1: type mismatch, expected number but got bool', 'E1138: Using a Bool as a Number') + enddef + + def Test_popup_hide() + CheckDefAndScriptFailure2(['popup_hide("a")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + CheckDefAndScriptFailure2(['popup_hide(true)'], 'E1013: Argument 1: type mismatch, expected number but got bool', 'E1138: Using a Bool as a Number') + enddef + def Test_popup_locate() CheckDefAndScriptFailure2(['popup_locate("a", 20)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') CheckDefAndScriptFailure2(['popup_locate(10, "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1030: Using a String as a Number') *************** *** 1559,1569 **** --- 1760,1785 ---- CheckDefAndScriptFailure2(['popup_menu("a", [1, 2])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') enddef + def Test_popup_move() + CheckDefAndScriptFailure2(['popup_move("x", {})'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1') + CheckDefAndScriptFailure2(['popup_move(1, [])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2') + enddef + def Test_popup_notification() CheckDefAndScriptFailure2(['popup_notification({"a": 10}, {})'], 'E1013: Argument 1: type mismatch, expected string but got dict', 'E450: buffer number, text or a list required') CheckDefAndScriptFailure2(['popup_notification("a", [1, 2])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') enddef + def Test_popup_setoptions() + CheckDefAndScriptFailure2(['popup_setoptions("x", {})'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1') + CheckDefAndScriptFailure2(['popup_setoptions(1, [])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2') + enddef + + def Test_popup_show() + CheckDefAndScriptFailure2(['popup_show("a")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + CheckDefAndScriptFailure2(['popup_show(true)'], 'E1013: Argument 1: type mismatch, expected number but got bool', 'E1138: Using a Bool as a Number') + enddef + def Test_prevnonblank() CheckDefFailure(['prevnonblank(null)'], 'E1013: Argument 1: type mismatch, expected string but got special') assert_equal(0, prevnonblank(1)) *************** *** 1582,1587 **** --- 1798,1808 ---- CheckDefAndScriptFailure2(['prop_find({"a": 10}, ["a"])'], 'E1013: Argument 2: type mismatch, expected string but got list', 'E730: Using a List as a String') enddef + def Test_prop_list() + CheckDefAndScriptFailure2(['prop_list("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1') + CheckDefAndScriptFailure2(['prop_list(1, [])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2') + enddef + def Test_prop_type_add() CheckDefAndScriptFailure2(['prop_type_add({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict', 'E731: Using a Dictionary as a String') CheckDefAndScriptFailure2(['prop_type_add("a", "b")'], 'E1013: Argument 2: type mismatch, expected dict but got string', 'E715: Dictionary required') *************** *** 1604,1609 **** --- 1825,1856 ---- CheckDefAndScriptFailure2(['prop_type_get("a", "b")'], 'E1013: Argument 2: type mismatch, expected dict but got string', 'E715: Dictionary required') enddef + def Test_prop_type_list() + CheckDefAndScriptFailure2(['prop_type_list(["a"])'], 'E1013: Argument 1: type mismatch, expected dict but got list', 'E715: Dictionary required') + CheckDefAndScriptFailure2(['prop_type_list(2)'], 'E1013: Argument 1: type mismatch, expected dict but got number', 'E715: Dictionary required') + enddef + + def Test_py3eval() + if !has('python3') + CheckFeature python3 + endif + CheckDefAndScriptFailure2(['py3eval([2])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + enddef + + def Test_pyeval() + if !has('python') + CheckFeature python + endif + CheckDefAndScriptFailure2(['pyeval([2])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + enddef + + def Test_pyxeval() + if !has('python') && !has('python3') + CheckFeature python + endif + CheckDefAndScriptFailure2(['pyxeval([2])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + enddef + def Test_rand() CheckDefFailure(['rand(10)'], 'E1013: Argument 1: type mismatch, expected list but got number') CheckDefFailure(['rand(["a"])'], 'E1013: Argument 1: type mismatch, expected list but got list') *************** *** 1704,1709 **** --- 1951,1963 ---- CheckDefAndScriptFailure2(['remote_peek("a5b6c7", [1])'], 'E1013: Argument 2: type mismatch, expected string but got list', 'E573: Invalid server id used') enddef + def Test_remote_read() + CheckFeature clientserver + CheckEnv DISPLAY + CheckDefAndScriptFailure2(['remote_read(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['remote_read("a", "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + def Test_remote_startserver() CheckFeature clientserver CheckEnv DISPLAY *************** *** 1743,1748 **** --- 1997,2009 ---- res->assert_equal(6) enddef + def Test_rubyeval() + if !has('ruby') + CheckFeature ruby + endif + CheckDefAndScriptFailure2(['rubyeval([2])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + enddef + def Test_screenattr() CheckDefFailure(['screenattr("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string') CheckDefFailure(['screenattr(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string') *************** *** 1813,1818 **** --- 2074,2080 ---- maxcount: 99, incomplete: 0}) bwipe! + CheckDefAndScriptFailure2(['searchcount([1])'], 'E1013: Argument 1: type mismatch, expected dict but got list', 'E715: Dictionary required') enddef def Test_searchpair() *************** *** 1956,1961 **** --- 2218,2244 ---- CheckDefFailure(['setfperm("a", 0z10)'], 'E1013: Argument 2: type mismatch, expected string but got blob') enddef + def Test_setbufline() + new + var bnum = bufnr('%') + :wincmd w + setbufline(bnum, 1, range(1, 3)) + setbufline(bnum, 4, 'one') + setbufline(bnum, 5, 10) + setbufline(bnum, 6, ['two', 11]) + assert_equal(['1', '2', '3', 'one', '10', 'two', '11'], getbufline(bnum, 1, '$')) + CheckDefFailure(['setbufline([1], 1, "x")'], 'E1013: Argument 1: type mismatch, expected string but got list') + CheckDefFailure(['setbufline(1, [1], "x")'], 'E1013: Argument 2: type mismatch, expected string but got list') + CheckDefFailure(['setbufline(1, 1, {"a": 10})'], 'E1013: Argument 3: type mismatch, expected string but got dict') + bnum->bufwinid()->win_gotoid() + bw! + enddef + + def Test_setcellwidths() + CheckDefAndScriptFailure2(['setcellwidths(1)'], 'E1013: Argument 1: type mismatch, expected list but got number', 'E714: List required') + CheckDefAndScriptFailure2(['setcellwidths({"a": 10})'], 'E1013: Argument 1: type mismatch, expected list but got dict', 'E714: List required') + enddef + def Test_setline() new setline(1, range(1, 4)) *************** *** 1964,1969 **** --- 2247,2255 ---- assert_equal(['a', 'b', 'c', 'd'], getline(1, '$')) setline(1, 'one') assert_equal(['one', 'b', 'c', 'd'], getline(1, '$')) + setline(1, 10) + assert_equal(['10', 'b', 'c', 'd'], getline(1, '$')) + CheckDefAndScriptFailure2(['setline([1], "x")'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E745: Using a List as a Number') bw! enddef *************** *** 1998,2003 **** --- 2284,2299 ---- CheckDefAndScriptFailure2(['sign_define("a", ["b"])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') enddef + def Test_sign_getdefined() + CheckDefAndScriptFailure2(['sign_getdefined(["x"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['sign_getdefined(2)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + enddef + + def Test_sign_placelist() + CheckDefAndScriptFailure2(['sign_placelist("x")'], 'E1013: Argument 1: type mismatch, expected list but got string', 'E714: List required') + CheckDefAndScriptFailure2(['sign_placelist({"a": 10})'], 'E1013: Argument 1: type mismatch, expected list but got dict', 'E714: List required') + enddef + def Test_sign_undefine() CheckDefAndScriptFailure2(['sign_undefine({})'], 'E1013: Argument 1: type mismatch, expected string but got dict', 'E731: Using a Dictionary as a String') CheckDefAndScriptFailure2(['sign_undefine([1])'], 'E1013: Argument 1: type mismatch, expected list but got list', 'E155: Unknown sign:') *************** *** 2009,2014 **** --- 2305,2315 ---- CheckDefAndScriptFailure2(['sign_unplace("a", ["b"])'], 'E1013: Argument 2: type mismatch, expected dict but got list', 'E715: Dictionary required') enddef + def Test_sign_unplacelist() + CheckDefAndScriptFailure2(['sign_unplacelist("x")'], 'E1013: Argument 1: type mismatch, expected list but got string', 'E714: List required') + CheckDefAndScriptFailure2(['sign_unplacelist({"a": 10})'], 'E1013: Argument 1: type mismatch, expected list but got dict', 'E714: List required') + enddef + def Test_simplify() CheckDefFailure(['simplify(100)'], 'E1013: Argument 1: type mismatch, expected string but got number') call assert_equal('NonExistingFile', simplify('NonExistingFile')) *************** *** 2117,2126 **** --- 2418,2448 ---- CheckScriptFailure(['vim9script', 'echo str2nr("123", 10, "x")'], 'E1135:') enddef + def Test_strcharlen() + CheckDefAndScriptFailure2(['strcharlen([1])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') + "abc"->strcharlen()->assert_equal(3) + strcharlen(99)->assert_equal(2) + enddef + def Test_strchars() strchars("A\u20dd", true)->assert_equal(1) enddef + def Test_strdisplaywidth() + CheckDefAndScriptFailure2(['strdisplaywidth(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['strdisplaywidth("a", "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + + def Test_strftime() + CheckDefAndScriptFailure2(['strftime(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['strftime("a", "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + + def Test_strgetchar() + CheckDefAndScriptFailure2(['strgetchar(1, 1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['strgetchar("a", "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + def Test_stridx() CheckDefAndScriptFailure2(['stridx([1], "b")'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') CheckDefAndScriptFailure2(['stridx("a", {})'], 'E1013: Argument 2: type mismatch, expected string but got dict', 'E731: Using a Dictionary as a String') *************** *** 2211,2216 **** --- 2533,2543 ---- assert_equal(1, tabpagenr()) enddef + def Test_tabpagewinnr() + CheckDefAndScriptFailure2(['tabpagewinnr("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1') + CheckDefAndScriptFailure2(['tabpagewinnr(1, 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2') + enddef + def Test_taglist() CheckDefAndScriptFailure2(['taglist([1])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E730: Using a List as a String') CheckDefAndScriptFailure2(['taglist("a", [2])'], 'E1013: Argument 2: type mismatch, expected string but got list', 'E730: Using a List as a String') *************** *** 2234,2239 **** --- 2561,2572 ---- CheckDefAndScriptFailure2(['term_getansicolors(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E745: Using a List as a Number') enddef + def Test_term_getattr() + CheckRunVimInTerminal + CheckDefAndScriptFailure2(['term_getattr("x", "a")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1') + CheckDefAndScriptFailure2(['term_getattr(1, 2)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2') + enddef + def Test_term_getcursor() CheckRunVimInTerminal CheckDefAndScriptFailure2(['term_getcursor({"a": 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict', 'E728: Using a Dictionary as a Number') *************** *** 2310,2315 **** --- 2643,2653 ---- CheckDefAndScriptFailure2(['test_option_not_set([])'], 'E1013: Argument 1: type mismatch, expected string but got list', 'E474: Invalid argument') enddef + def Test_test_override() + CheckDefAndScriptFailure2(['test_override(1, 1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1') + CheckDefAndScriptFailure2(['test_override("a", "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2') + enddef + def Test_test_setmouse() CheckDefAndScriptFailure2(['test_setmouse("a", 10)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E474: Invalid argument') CheckDefAndScriptFailure2(['test_setmouse(10, "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E474: Invalid argument') *************** *** 2392,2397 **** --- 2730,2740 ---- bw! enddef + def Test_visualmode() + CheckDefFailure(['visualmode("1")'], 'E1013: Argument 1: type mismatch, expected bool but got string') + CheckDefFailure(['visualmode(2)'], 'E1013: Argument 1: type mismatch, expected bool but got number') + enddef + def Test_win_execute() assert_equal("\n" .. winnr(), win_execute(win_getid(), 'echo winnr()')) assert_equal("\n" .. winnr(), 'echo winnr()'->win_execute(win_getid())) *************** *** 2411,2422 **** --- 2754,2797 ---- assert_equal(win_getid(), win_getid(1, 1)) enddef + def Test_win_gettype() + CheckDefAndScriptFailure2(['win_gettype("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + enddef + + def Test_win_gotoid() + CheckDefAndScriptFailure2(['win_gotoid("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + enddef + + def Test_win_id2tabwin() + CheckDefAndScriptFailure2(['win_id2tabwin("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + enddef + + def Test_win_id2win() + CheckDefAndScriptFailure2(['win_id2win("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + enddef + + def Test_win_screenpos() + CheckDefAndScriptFailure2(['win_screenpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + enddef + def Test_win_splitmove() split win_splitmove(1, 2, {vertical: true, rightbelow: true}) close enddef + def Test_winbufnr() + CheckDefAndScriptFailure2(['winbufnr("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + enddef + + def Test_winheight() + CheckDefAndScriptFailure2(['winheight("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + enddef + + def Test_winlayout() + CheckDefAndScriptFailure2(['winlayout("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') + enddef + def Test_winnr() CheckDefFailure(['winnr([])'], 'E1013: Argument 1: type mismatch, expected string but got list') assert_equal(1, winnr()) *************** *** 2449,2486 **** CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list but got dict', 1) enddef - def Test_win_gettype() - CheckDefAndScriptFailure2(['win_gettype("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') - enddef - - def Test_win_gotoid() - CheckDefAndScriptFailure2(['win_gotoid("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') - enddef - - def Test_win_id2tabwin() - CheckDefAndScriptFailure2(['win_id2tabwin("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') - enddef - - def Test_win_id2win() - CheckDefAndScriptFailure2(['win_id2win("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') - enddef - - def Test_win_screenpos() - CheckDefAndScriptFailure2(['win_screenpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') - enddef - - def Test_winbufnr() - CheckDefAndScriptFailure2(['winbufnr("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') - enddef - - def Test_winheight() - CheckDefAndScriptFailure2(['winheight("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') - enddef - - def Test_winlayout() - CheckDefAndScriptFailure2(['winlayout("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') - enddef - def Test_winwidth() CheckDefAndScriptFailure2(['winwidth("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number') enddef --- 2824,2829 ---- *** ../vim-8.2.3161/src/testdir/test_vim9_expr.vim 2021-07-11 20:58:54.788028521 +0200 --- src/testdir/test_vim9_expr.vim 2021-07-15 10:53:45.242392507 +0200 *************** *** 2982,2988 **** enddef RetVoid()->byteidx(3) END ! CheckDefExecAndScriptFailure(lines, 'E1031:') enddef --- 2982,2988 ---- enddef RetVoid()->byteidx(3) END ! CheckDefExecFailure(lines, 'E1013:') enddef *** ../vim-8.2.3161/src/testing.c 2021-07-11 19:44:14.114416536 +0200 --- src/testing.c 2021-07-15 10:53:45.242392507 +0200 *************** *** 340,349 **** static int assert_beeps(typval_T *argvars, int no_beep) { ! char_u *cmd = tv_get_string_chk(&argvars[0]); garray_T ga; int ret = 0; called_vim_beep = FALSE; suppress_errthrow = TRUE; emsg_silent = FALSE; --- 340,353 ---- static int assert_beeps(typval_T *argvars, int no_beep) { ! char_u *cmd; garray_T ga; int ret = 0; + if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + return 0; + + cmd = tv_get_string_chk(&argvars[0]); called_vim_beep = FALSE; suppress_errthrow = TRUE; emsg_silent = FALSE; *************** *** 367,373 **** } /* ! * "assert_beeps(cmd [, error])" function */ void f_assert_beeps(typval_T *argvars, typval_T *rettv) --- 371,377 ---- } /* ! * "assert_beeps(cmd)" function */ void f_assert_beeps(typval_T *argvars, typval_T *rettv) *************** *** 376,382 **** } /* ! * "assert_nobeep(cmd [, error])" function */ void f_assert_nobeep(typval_T *argvars, typval_T *rettv) --- 380,386 ---- } /* ! * "assert_nobeep(cmd)" function */ void f_assert_nobeep(typval_T *argvars, typval_T *rettv) *************** *** 947,952 **** --- 951,961 ---- int val; static int save_starting = -1; + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || check_for_number_arg(argvars, 1) == FAIL)) + return; + if (argvars[0].v_type != VAR_STRING || (argvars[1].v_type) != VAR_NUMBER) emsg(_(e_invarg)); *** ../vim-8.2.3161/src/textprop.c 2021-07-10 13:15:35.295053013 +0200 --- src/textprop.c 2021-07-15 10:53:45.242392507 +0200 *************** *** 769,777 **** void f_prop_list(typval_T *argvars, typval_T *rettv) { ! linenr_T lnum = tv_get_number(&argvars[0]); buf_T *buf = curbuf; if (argvars[1].v_type != VAR_UNKNOWN) { if (get_bufnr_from_arg(&argvars[1], &buf) == FAIL) --- 769,784 ---- void f_prop_list(typval_T *argvars, typval_T *rettv) { ! linenr_T lnum; buf_T *buf = curbuf; + if (in_vim9script() + && (check_for_number_arg(argvars, 0) == FAIL + || (argvars[1].v_type != VAR_UNKNOWN && + check_for_dict_arg(argvars, 1) == FAIL))) + return; + + lnum = tv_get_number(&argvars[0]); if (argvars[1].v_type != VAR_UNKNOWN) { if (get_bufnr_from_arg(&argvars[1], &buf) == FAIL) *** ../vim-8.2.3161/src/time.c 2021-07-14 21:00:38.065084719 +0200 --- src/time.c 2021-07-15 10:53:45.242392507 +0200 *************** *** 169,174 **** --- 169,178 ---- # ifdef FEAT_RELTIME proftime_T res; proftime_T start; + long n1, n2; + + if (rettv_list_alloc(rettv) != OK) + return; if (argvars[0].v_type == VAR_UNKNOWN) { *************** *** 198,217 **** profile_sub(&res, &start); } - if (rettv_list_alloc(rettv) == OK) - { - long n1, n2; - # ifdef MSWIN ! n1 = res.HighPart; ! n2 = res.LowPart; # else ! n1 = res.tv_sec; ! n2 = res.tv_usec; # endif ! list_append_number(rettv->vval.v_list, (varnumber_T)n1); ! list_append_number(rettv->vval.v_list, (varnumber_T)n2); ! } # endif } --- 202,216 ---- profile_sub(&res, &start); } # ifdef MSWIN ! n1 = res.HighPart; ! n2 = res.LowPart; # else ! n1 = res.tv_sec; ! n2 = res.tv_usec; # endif ! list_append_number(rettv->vval.v_list, (varnumber_T)n1); ! list_append_number(rettv->vval.v_list, (varnumber_T)n2); # endif } *************** *** 269,274 **** --- 268,279 ---- time_t seconds; char_u *p; + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || (argvars[1].v_type != VAR_UNKNOWN + && check_for_number_arg(argvars, 1) == FAIL))) + return; + rettv->v_type = VAR_STRING; p = tv_get_string(&argvars[0]); *** ../vim-8.2.3161/src/typval.c 2021-07-10 13:15:35.295053013 +0200 --- src/typval.c 2021-07-15 10:53:45.242392507 +0200 *************** *** 385,390 **** --- 385,407 ---- } /* + * Give an error and return FAIL unless "tv" is a number. + */ + int + check_for_number_arg(typval_T *args, int idx) + { + if (args[idx].v_type != VAR_NUMBER) + { + if (idx >= 0) + semsg(_(e_number_required_for_argument_nr), idx + 1); + else + emsg(_(e_numberreq)); + return FAIL; + } + return OK; + } + + /* * Give an error and return FAIL unless "tv" is a dict. */ int *** ../vim-8.2.3161/src/version.c 2021-07-14 21:00:38.065084719 +0200 --- src/version.c 2021-07-15 10:55:23.678141626 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3162, /**/ -- We are the Borg of GNU GPL. We will assimilate your source code. Resistance is futile. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///