Compare commits

...

20 Commits

Author SHA1 Message Date
c323527d67 patch 8.2.3137: Vim9: no error when a line only has a variable name
Problem:    Vim9: no error when a line only has a variable name.
Solution:   Give an error when an expression is evaluated without an effect.
            (closes #8538)
2021-07-10 19:42:03 +02:00
fe3418abe0 patch 8.2.3136: no test for E187 and "No swap file"
Problem:    No test for E187 and "No swap file".
Solution:   Add a test. (Dominique Pellé, closes #8540)
2021-07-10 17:59:48 +02:00
5b73992d8f patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Problem:    Vim9: builtin function arguments not checked at compile time.
Solution:   Add more type checks. (Yegappan Lakshmanan, closes #8539)
2021-07-10 13:15:41 +02:00
9da32e4d57 patch 8.2.3134: crash when using typename() on a function reference
Problem:    Crash when using typename() on a function reference. (Naohiro Ono)
Solution:   Initialize pointer to NULL. (closes #8531)
2021-07-09 19:53:57 +02:00
90fba5627b patch 8.2.3133: Vim9: memory leak when add() fails
Problem:    Vim9: memory leak when add() fails.
Solution:   Allocate listitem_T after type check.
2021-07-09 19:17:55 +02:00
6bcb18253a patch 8.2.3132: compiler warns for size_t to colnr_T conversion.
Problem:    Compiler warns for size_t to colnr_T conversion. (Randall W.
            Morris)
Solution:   Add a type cast.
2021-07-09 15:54:00 +02:00
981217c11f patch 8.2.3131: MS-Windows: ipv6 channel test is very flaky in the GUI
Problem:    MS-Windows: ipv6 channel test is very flaky in the GUI.
Solution:   Skip the test.
2021-07-08 22:20:50 +02:00
b885a7c72c patch 8.2.3130: Vim9: import test fails
Problem:    Vim9: import test fails.
Solution:   Rename directory back to "import", use "p" to avoid an error when
            the directory already exists.
2021-07-08 22:02:11 +02:00
c967d57aa9 patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Problem:    Vim9: imported uninitialized list does not get type checked.
Solution:   Get type from imported variable.
2021-07-08 21:38:50 +02:00
f055d45023 patch 8.2.3128: Vim9: uninitialzed list does not get type checked
Problem:    Vim9: uninitialzed list does not get type checked.
Solution:   Set the type when initializing the variable. (closes #8529)
2021-07-08 20:57:24 +02:00
f32f099761 patch 8.2.3127: Vim9: no error when adding number to list of string
Problem:    Vim9: no error when adding number to list of string.
Solution:   Check the value type. (closes #8529)
2021-07-08 20:53:40 +02:00
d4ab807d62 patch 8.2.3126: Vim9: for loop error reports wrong line number
Problem:    Vim9: for loop error reports wrong line number.
Solution:   Save and restore the line number when evaluating the expression.
            (closes #8514)
2021-07-08 19:22:12 +02:00
09f688c33a patch 8.2.3125: variables are set but not used
Problem:    Variables are set but not used.
Solution:   Move the declarations to the block where they are used.
            (closes #8527)
2021-07-08 18:05:00 +02:00
deb108ba0a patch 8.2.3124: Vim9: no error for white space between option and "=9"
Problem:    Vim9: no error for white space between option and "=9".
Solution:   Check for extraneous white space. (issue #8408)
2021-07-08 17:35:36 +02:00
1594f31345 patch 8.2.3123: Vim9: confusing error when using white space after option
Problem:    Vim9: confusing error when using white space after option, before
            one of "!&<".
Solution:   Give a specific error. (issue #8408)
2021-07-08 16:40:13 +02:00
30441bb3d5 patch 8.2.3122: with 'nowrap' cursor position is unexected in narrow window
Problem:    With 'nowrap' cursor position is unexected in narrow window.
            (Leonid V.  Fedorenchik)
Solution:   Put cursor on the last non-empty line. (closes #8525)
2021-07-08 13:19:31 +02:00
41fb723ee9 patch 8.2.3121: 'listchars' "exceeds" character appears in foldcolumn
Problem:    'listchars' "exceeds" character appears in foldcolumn. Window
            separator is missing. (Leonid V.  Fedorenchik)
Solution:   Only draw the "exceeds" character in the text area.  Break the
            loop when not drawing the text. (closes #8524)
2021-07-08 12:40:05 +02:00
db86472770 patch 8.2.3120: crypt with sodium test fails on MS-Windows
Problem:    Crypt with sodium test fails on MS-Windows.
Solution:   Make the tests pass. (closes #8428)
2021-07-08 11:37:50 +02:00
6a9e5c69cf patch 8.2.3119: compiler warning for unused argument
Problem:    Compiler warning for unused argument.
Solution:   Add UNUSED.
2021-07-07 22:13:08 +02:00
5ede5b231e patch 8.2.3118: Vim9: "any" type not handled correctly in for loop
Problem:    Vim9: "any" type not handled correctly in for loop.
Solution:   Change compile time check into runtime check. (closes #8516)
2021-07-07 21:55:25 +02:00
38 changed files with 982 additions and 232 deletions

View File

@ -1311,6 +1311,11 @@ channel_open_func(typval_T *argvars)
jobopt_T opt;
channel_T *channel = NULL;
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_dict_arg(argvars, 1) == FAIL))
return NULL;
address = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN
&& (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL))

View File

@ -2783,6 +2783,7 @@ win_line(
// Show "extends" character from 'listchars' if beyond the line end and
// 'list' is set.
if (wp->w_lcs_chars.ext != NUL
&& draw_state == WL_LINE
&& wp->w_p_list
&& !wp->w_p_wrap
#ifdef FEAT_DIFF
@ -3050,7 +3051,8 @@ win_line(
wp->w_p_rl ? (col < 0) :
#endif
(col >= wp->w_width))
&& (*ptr != NUL
&& (draw_state != WL_LINE
|| *ptr != NUL
#ifdef FEAT_DIFF
|| filler_todo > 0
#endif

View File

@ -2036,7 +2036,7 @@ win_update(win_T *wp)
{
colnr_T t;
pos.col = STRLEN(ml_get_buf(wp->w_buffer,
pos.col = (int)STRLEN(ml_get_buf(wp->w_buffer,
pos.lnum, FALSE));
getvvcol(wp, &pos, NULL, NULL, &t);
if (toc < t)

View File

@ -490,3 +490,9 @@ EXTERN char e_dot_can_only_be_used_on_dictionary_str[]
INIT(= N_("E1203: Dot can only be used on a dictionary: %s"));
EXTERN char e_regexp_number_after_dot_pos_search[]
INIT(= N_("E1204: No Number allowed after .: '\\%%%c'"));
EXTERN char e_no_white_space_allowed_between_option_and[]
INIT(= N_("E1205: No white space allowed between option and"));
EXTERN char e_dict_required_for_argument_nr[]
INIT(= N_("E1206: Dictionary required for argument %d"));
EXTERN char e_expression_without_effect_str[]
INIT(= N_("E1207: Expression without an effect: %s"));

View File

@ -374,6 +374,18 @@ arg_list_or_dict(type_T *type, argcontext_T *context)
return FAIL;
}
/*
* 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;
}
/*
* Check "type" is the same type as the previous argument.
* Must not be used for the first argcheck_T entry.
@ -444,15 +456,19 @@ arg_extend3(type_T *type, argcontext_T *context)
argcheck_T arg1_string[] = {arg_string};
argcheck_T arg1_number[] = {arg_number};
argcheck_T arg1_dict[] = {arg_dict_any};
argcheck_T arg1_list_number[] = {arg_list_number};
argcheck_T arg1_string_list[] = {arg_list_string};
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[] = {arg_string_or_list};
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_number[] = {arg_list_number, arg_list_number};
argcheck_T arg2_list_nr[] = {arg_list_number, arg_list_number};
argcheck_T arg2_dict_string[] = {arg_dict_any, arg_string};
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_execute[] = {arg_string_or_list, arg_string};
argcheck_T arg23_extend[] = {arg_list_or_dict, arg_same_as_prev, arg_extend3};
@ -460,6 +476,7 @@ argcheck_T arg23_extendnew[] = {arg_list_or_dict, arg_same_struct_as_prev, arg_e
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 arg3_insert[] = {arg_list_or_blob, arg_item_of_prev, arg_number};
/*
@ -522,7 +539,7 @@ ret_list_dict_any(int argcount UNUSED, type_T **argtypes UNUSED)
return &t_list_dict_any;
}
static type_T *
ret_list_items(int argcount, type_T **argtypes UNUSED)
ret_list_items(int argcount UNUSED, type_T **argtypes UNUSED)
{
return &t_list_list_any;
}
@ -750,9 +767,9 @@ static funcentry_T global_functions[] =
ret_number_bool, f_assert_beeps},
{"assert_equal", 2, 3, FEARG_2, NULL,
ret_number_bool, f_assert_equal},
{"assert_equalfile", 2, 3, FEARG_1, NULL,
{"assert_equalfile", 2, 3, FEARG_1, arg3_string,
ret_number_bool, f_assert_equalfile},
{"assert_exception", 1, 2, 0, NULL,
{"assert_exception", 1, 2, 0, arg2_string,
ret_number_bool, f_assert_exception},
{"assert_fails", 1, 5, FEARG_1, NULL,
ret_number_bool, f_assert_fails},
@ -760,13 +777,13 @@ static funcentry_T global_functions[] =
ret_number_bool, f_assert_false},
{"assert_inrange", 3, 4, FEARG_3, NULL,
ret_number_bool, f_assert_inrange},
{"assert_match", 2, 3, FEARG_2, NULL,
{"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},
{"assert_notmatch", 2, 3, FEARG_2, NULL,
{"assert_notmatch", 2, 3, FEARG_2, arg3_string,
ret_number_bool, f_assert_notmatch},
{"assert_report", 1, 1, FEARG_1, NULL,
ret_number_bool, f_assert_report},
@ -802,7 +819,7 @@ static funcentry_T global_functions[] =
},
{"browse", 4, 4, 0, NULL,
ret_string, f_browse},
{"browsedir", 2, 2, 0, NULL,
{"browsedir", 2, 2, 0, arg2_string,
ret_string, f_browsedir},
{"bufadd", 1, 1, FEARG_1, arg1_string,
ret_number, f_bufadd},
@ -838,11 +855,11 @@ static funcentry_T global_functions[] =
ret_any, f_call},
{"ceil", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_ceil)},
{"ch_canread", 1, 1, FEARG_1, NULL,
{"ch_canread", 1, 1, FEARG_1, arg1_chan_or_job,
ret_number_bool, JOB_FUNC(f_ch_canread)},
{"ch_close", 1, 1, FEARG_1, NULL,
{"ch_close", 1, 1, FEARG_1, arg1_chan_or_job,
ret_void, JOB_FUNC(f_ch_close)},
{"ch_close_in", 1, 1, FEARG_1, NULL,
{"ch_close_in", 1, 1, FEARG_1, arg1_chan_or_job,
ret_void, JOB_FUNC(f_ch_close_in)},
{"ch_evalexpr", 2, 3, FEARG_1, NULL,
ret_any, JOB_FUNC(f_ch_evalexpr)},
@ -852,13 +869,13 @@ static funcentry_T global_functions[] =
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, NULL,
{"ch_info", 1, 1, FEARG_1, arg1_chan_or_job,
ret_dict_any, JOB_FUNC(f_ch_info)},
{"ch_log", 1, 2, FEARG_1, NULL,
ret_void, JOB_FUNC(f_ch_log)},
{"ch_logfile", 1, 2, FEARG_1, NULL,
{"ch_logfile", 1, 2, FEARG_1, arg2_string,
ret_void, JOB_FUNC(f_ch_logfile)},
{"ch_open", 1, 2, FEARG_1, NULL,
{"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)},
@ -880,9 +897,9 @@ static funcentry_T global_functions[] =
ret_number, f_char2nr},
{"charclass", 1, 1, FEARG_1, arg1_string,
ret_number, f_charclass},
{"charcol", 1, 1, FEARG_1, NULL,
{"charcol", 1, 1, FEARG_1, arg1_string_or_list,
ret_number, f_charcol},
{"charidx", 2, 3, FEARG_1, NULL,
{"charidx", 2, 3, FEARG_1, arg3_string_nr_bool,
ret_number, f_charidx},
{"chdir", 1, 1, FEARG_1, arg1_string,
ret_string, f_chdir},
@ -890,7 +907,7 @@ static funcentry_T global_functions[] =
ret_number, f_cindent},
{"clearmatches", 0, 1, FEARG_1, arg1_number,
ret_void, f_clearmatches},
{"col", 1, 1, FEARG_1, NULL,
{"col", 1, 1, FEARG_1, arg1_string_or_list,
ret_number, f_col},
{"complete", 2, 2, FEARG_2, NULL,
ret_void, f_complete},
@ -898,7 +915,7 @@ static funcentry_T global_functions[] =
ret_number, f_complete_add},
{"complete_check", 0, 0, 0, NULL,
ret_number_bool, f_complete_check},
{"complete_info", 0, 1, FEARG_1, arg1_string_list,
{"complete_info", 0, 1, FEARG_1, arg1_list_string,
ret_dict_any, f_complete_info},
{"confirm", 1, 4, FEARG_1, NULL,
ret_number, f_confirm},
@ -924,7 +941,7 @@ static funcentry_T global_functions[] =
},
{"deepcopy", 1, 2, FEARG_1, NULL,
ret_first_arg, f_deepcopy},
{"delete", 1, 2, FEARG_1, NULL,
{"delete", 1, 2, FEARG_1, arg2_string,
ret_number_bool, f_delete},
{"deletebufline", 2, 3, FEARG_1, NULL,
ret_number_bool, f_deletebufline},
@ -974,9 +991,9 @@ static funcentry_T global_functions[] =
ret_number, f_filewritable},
{"filter", 2, 2, FEARG_1, NULL,
ret_first_arg, f_filter},
{"finddir", 1, 3, FEARG_1, NULL,
{"finddir", 1, 3, FEARG_1, arg3_string_string_nr,
ret_string, f_finddir},
{"findfile", 1, 3, FEARG_1, NULL,
{"findfile", 1, 3, FEARG_1, arg3_string_string_nr,
ret_string, f_findfile},
{"flatten", 1, 2, FEARG_1, NULL,
ret_list_any, f_flatten},
@ -1114,7 +1131,7 @@ static funcentry_T global_functions[] =
ret_any, f_globpath},
{"has", 1, 2, 0, NULL,
ret_number_bool, f_has},
{"has_key", 2, 2, FEARG_1, NULL,
{"has_key", 2, 2, FEARG_1, arg2_dict_string,
ret_number_bool, f_has_key},
{"haslocaldir", 0, 2, FEARG_1, arg2_number,
ret_number, f_haslocaldir},
@ -1140,15 +1157,15 @@ static funcentry_T global_functions[] =
ret_string, f_hostname},
{"iconv", 3, 3, FEARG_1, arg3_string,
ret_string, f_iconv},
{"indent", 1, 1, FEARG_1, NULL,
{"indent", 1, 1, FEARG_1, arg1_string_or_nr,
ret_number, f_indent},
{"index", 2, 4, FEARG_1, NULL,
ret_number, f_index},
{"input", 1, 3, FEARG_1, NULL,
{"input", 1, 3, FEARG_1, arg3_string,
ret_string, f_input},
{"inputdialog", 1, 3, FEARG_1, NULL,
{"inputdialog", 1, 3, FEARG_1, arg3_string,
ret_string, f_inputdialog},
{"inputlist", 1, 1, FEARG_1, arg1_string_list,
{"inputlist", 1, 1, FEARG_1, arg1_list_string,
ret_number, f_inputlist},
{"inputrestore", 0, 0, 0, NULL,
ret_number_bool, f_inputrestore},
@ -1196,7 +1213,7 @@ static funcentry_T global_functions[] =
ret_string, f_json_encode},
{"keys", 1, 1, FEARG_1, arg1_dict,
ret_list_string, f_keys},
{"last_buffer_nr", 0, 0, 0, NULL, // obsolete
{"last_buffer_nr", 0, 0, 0, arg1_string_or_nr, // obsolete
ret_number, f_last_buffer_nr},
{"len", 1, 1, FEARG_1, NULL,
ret_number, f_len},
@ -1214,7 +1231,7 @@ static funcentry_T global_functions[] =
ret_string, f_list2str},
{"listener_add", 1, 2, FEARG_2, NULL,
ret_number, f_listener_add},
{"listener_flush", 0, 1, FEARG_1, NULL,
{"listener_flush", 0, 1, FEARG_1, arg1_string_or_nr,
ret_void, f_listener_flush},
{"listener_remove", 1, 1, FEARG_1, arg1_number,
ret_number_bool, f_listener_remove},
@ -1276,7 +1293,7 @@ static funcentry_T global_functions[] =
},
{"min", 1, 1, FEARG_1, NULL,
ret_number, f_min},
{"mkdir", 1, 3, FEARG_1, NULL,
{"mkdir", 1, 3, FEARG_1, arg3_string_string_nr,
ret_number_bool, f_mkdir},
{"mode", 0, 1, FEARG_1, NULL,
ret_string, f_mode},
@ -1332,7 +1349,7 @@ static funcentry_T global_functions[] =
ret_void, PROP_FUNC(f_popup_hide)},
{"popup_list", 0, 0, 0, NULL,
ret_list_number, PROP_FUNC(f_popup_list)},
{"popup_locate", 2, 2, 0, NULL,
{"popup_locate", 2, 2, 0, arg2_number,
ret_number, PROP_FUNC(f_popup_locate)},
{"popup_menu", 2, 2, FEARG_1, NULL,
ret_number, PROP_FUNC(f_popup_menu)},
@ -1364,19 +1381,19 @@ static funcentry_T global_functions[] =
ret_void, PROP_FUNC(f_prop_add)},
{"prop_clear", 1, 3, FEARG_1, NULL,
ret_void, PROP_FUNC(f_prop_clear)},
{"prop_find", 1, 2, FEARG_1, NULL,
{"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)},
{"prop_type_add", 2, 2, FEARG_1, NULL,
{"prop_type_add", 2, 2, FEARG_1, arg2_string_dict,
ret_void, PROP_FUNC(f_prop_type_add)},
{"prop_type_change", 2, 2, FEARG_1, NULL,
{"prop_type_change", 2, 2, FEARG_1, arg2_string_dict,
ret_void, PROP_FUNC(f_prop_type_change)},
{"prop_type_delete", 1, 2, FEARG_1, NULL,
{"prop_type_delete", 1, 2, FEARG_1, arg2_string_dict,
ret_void, PROP_FUNC(f_prop_type_delete)},
{"prop_type_get", 1, 2, FEARG_1, NULL,
{"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)},
@ -1408,9 +1425,9 @@ static funcentry_T global_functions[] =
NULL
#endif
},
{"rand", 0, 1, FEARG_1, arg1_list_number,
{"rand", 0, 1, FEARG_1, arg1_list_nr,
ret_number, f_rand},
{"range", 1, 3, FEARG_1, NULL,
{"range", 1, 3, FEARG_1, arg3_number,
ret_list_number, f_range},
{"readblob", 1, 1, FEARG_1, arg1_string,
ret_blob, f_readblob},
@ -1418,7 +1435,7 @@ static funcentry_T global_functions[] =
ret_list_string, f_readdir},
{"readdirex", 1, 3, FEARG_1, NULL,
ret_list_dict_any, f_readdirex},
{"readfile", 1, 3, FEARG_1, NULL,
{"readfile", 1, 3, FEARG_1, arg3_string_string_nr,
ret_list_string, f_readfile},
{"reduce", 2, 3, FEARG_1, NULL,
ret_any, f_reduce},
@ -1426,17 +1443,17 @@ static funcentry_T global_functions[] =
ret_string, f_reg_executing},
{"reg_recording", 0, 0, 0, NULL,
ret_string, f_reg_recording},
{"reltime", 0, 2, FEARG_1, arg2_list_number,
{"reltime", 0, 2, FEARG_1, arg2_list_nr,
ret_list_any, f_reltime},
{"reltimefloat", 1, 1, FEARG_1, arg1_list_number,
{"reltimefloat", 1, 1, FEARG_1, arg1_list_nr,
ret_float, FLOAT_FUNC(f_reltimefloat)},
{"reltimestr", 1, 1, FEARG_1, arg1_list_number,
{"reltimestr", 1, 1, FEARG_1, arg1_list_nr,
ret_string, f_reltimestr},
{"remote_expr", 2, 4, FEARG_1, NULL,
ret_string, f_remote_expr},
{"remote_foreground", 1, 1, FEARG_1, arg1_string,
ret_string, f_remote_foreground},
{"remote_peek", 1, 2, FEARG_1, NULL,
{"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},
@ -1452,7 +1469,7 @@ static funcentry_T global_functions[] =
ret_first_arg, f_repeat},
{"resolve", 1, 1, FEARG_1, arg1_string,
ret_string, f_resolve},
{"reverse", 1, 1, FEARG_1, NULL,
{"reverse", 1, 1, FEARG_1, arg1_list_or_blob,
ret_first_arg, f_reverse},
{"round", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_round)},
@ -1490,7 +1507,7 @@ static funcentry_T global_functions[] =
ret_list_number, f_searchpairpos},
{"searchpos", 1, 5, FEARG_1, NULL,
ret_list_number, f_searchpos},
{"server2client", 2, 2, FEARG_1, NULL,
{"server2client", 2, 2, FEARG_1, arg2_string,
ret_number_bool, f_server2client},
{"serverlist", 0, 0, 0, NULL,
ret_string, f_serverlist},
@ -1544,7 +1561,7 @@ static funcentry_T global_functions[] =
ret_string, f_shellescape},
{"shiftwidth", 0, 1, FEARG_1, arg1_number,
ret_number, f_shiftwidth},
{"sign_define", 1, 2, FEARG_1, NULL,
{"sign_define", 1, 2, FEARG_1, arg2_string_dict,
ret_any, SIGN_FUNC(f_sign_define)},
{"sign_getdefined", 0, 1, FEARG_1, NULL,
ret_list_dict_any, SIGN_FUNC(f_sign_getdefined)},
@ -1556,9 +1573,9 @@ static funcentry_T global_functions[] =
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, NULL,
{"sign_undefine", 0, 1, FEARG_1, arg1_string_or_list,
ret_number_bool, SIGN_FUNC(f_sign_undefine)},
{"sign_unplace", 1, 2, FEARG_1, NULL,
{"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)},
@ -1618,7 +1635,7 @@ static funcentry_T global_functions[] =
},
{"strgetchar", 2, 2, FEARG_1, NULL,
ret_number, f_strgetchar},
{"stridx", 2, 3, FEARG_1, NULL,
{"stridx", 2, 3, FEARG_1, arg3_string_string_nr,
ret_number, f_stridx},
{"string", 1, 1, FEARG_1, NULL,
ret_string, f_string},
@ -1634,7 +1651,7 @@ static funcentry_T global_functions[] =
NULL
#endif
},
{"strridx", 2, 3, FEARG_1, NULL,
{"strridx", 2, 3, FEARG_1, arg3_string_string_nr,
ret_number, f_strridx},
{"strtrans", 1, 1, FEARG_1, arg1_string,
ret_string, f_strtrans},
@ -1670,7 +1687,7 @@ static funcentry_T global_functions[] =
ret_number, f_tabpagewinnr},
{"tagfiles", 0, 0, 0, NULL,
ret_list_string, f_tagfiles},
{"taglist", 1, 2, FEARG_1, NULL,
{"taglist", 1, 2, FEARG_1, arg2_string,
ret_list_dict_any, f_taglist},
{"tan", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_tan)},
@ -1680,13 +1697,13 @@ static funcentry_T global_functions[] =
ret_string, f_tempname},
{"term_dumpdiff", 2, 3, FEARG_1, NULL,
ret_number, TERM_FUNC(f_term_dumpdiff)},
{"term_dumpload", 1, 2, FEARG_1, NULL,
{"term_dumpload", 1, 2, FEARG_1, arg2_string_dict,
ret_number, TERM_FUNC(f_term_dumpload)},
{"term_dumpwrite", 2, 3, FEARG_2, NULL,
ret_void, TERM_FUNC(f_term_dumpwrite)},
{"term_getaltscreen", 1, 1, FEARG_1, NULL,
{"term_getaltscreen", 1, 1, FEARG_1, arg1_string_or_nr,
ret_number, TERM_FUNC(f_term_getaltscreen)},
{"term_getansicolors", 1, 1, FEARG_1, NULL,
{"term_getansicolors", 1, 1, FEARG_1, arg1_string_or_nr,
ret_list_string,
#if defined(FEAT_TERMINAL) && (defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS))
f_term_getansicolors
@ -1696,19 +1713,19 @@ static funcentry_T global_functions[] =
},
{"term_getattr", 2, 2, FEARG_1, NULL,
ret_number, TERM_FUNC(f_term_getattr)},
{"term_getcursor", 1, 1, FEARG_1, NULL,
{"term_getcursor", 1, 1, FEARG_1, arg1_string_or_nr,
ret_list_any, TERM_FUNC(f_term_getcursor)},
{"term_getjob", 1, 1, FEARG_1, NULL,
{"term_getjob", 1, 1, FEARG_1, arg1_string_or_nr,
ret_job, TERM_FUNC(f_term_getjob)},
{"term_getline", 2, 2, FEARG_1, NULL,
ret_string, TERM_FUNC(f_term_getline)},
{"term_getscrolled", 1, 1, FEARG_1, NULL,
{"term_getscrolled", 1, 1, FEARG_1, arg1_string_or_nr,
ret_number, TERM_FUNC(f_term_getscrolled)},
{"term_getsize", 1, 1, FEARG_1, NULL,
{"term_getsize", 1, 1, FEARG_1, arg1_string_or_nr,
ret_list_number, TERM_FUNC(f_term_getsize)},
{"term_getstatus", 1, 1, FEARG_1, NULL,
{"term_getstatus", 1, 1, FEARG_1, arg1_string_or_nr,
ret_string, TERM_FUNC(f_term_getstatus)},
{"term_gettitle", 1, 1, FEARG_1, NULL,
{"term_gettitle", 1, 1, FEARG_1, arg1_string_or_nr,
ret_string, TERM_FUNC(f_term_gettitle)},
{"term_gettty", 1, 2, FEARG_1, NULL,
ret_string, TERM_FUNC(f_term_gettty)},
@ -1740,23 +1757,23 @@ static funcentry_T global_functions[] =
ret_void, TERM_FUNC(f_term_wait)},
{"terminalprops", 0, 0, 0, NULL,
ret_dict_string, f_terminalprops},
{"test_alloc_fail", 3, 3, FEARG_1, NULL,
{"test_alloc_fail", 3, 3, FEARG_1, arg3_number,
ret_void, f_test_alloc_fail},
{"test_autochdir", 0, 0, 0, NULL,
ret_void, f_test_autochdir},
{"test_feedinput", 1, 1, FEARG_1, NULL,
{"test_feedinput", 1, 1, FEARG_1, arg1_string,
ret_void, f_test_feedinput},
{"test_garbagecollect_now", 0, 0, 0, NULL,
ret_void, f_test_garbagecollect_now},
{"test_garbagecollect_soon", 0, 0, 0, NULL,
ret_void, f_test_garbagecollect_soon},
{"test_getvalue", 1, 1, FEARG_1, NULL,
{"test_getvalue", 1, 1, FEARG_1, arg1_string,
ret_number, f_test_getvalue},
{"test_gui_drop_files", 4, 4, 0, NULL,
ret_void, f_test_gui_drop_files},
{"test_gui_mouse_event", 5, 5, 0, NULL,
ret_void, f_test_gui_mouse_event},
{"test_ignore_error", 1, 1, FEARG_1, NULL,
{"test_ignore_error", 1, 1, FEARG_1, arg1_string,
ret_void, f_test_ignore_error},
{"test_null_blob", 0, 0, 0, NULL,
ret_blob, f_test_null_blob},
@ -1774,7 +1791,7 @@ static funcentry_T global_functions[] =
ret_func_any, f_test_null_partial},
{"test_null_string", 0, 0, 0, NULL,
ret_string, f_test_null_string},
{"test_option_not_set", 1, 1, FEARG_1, NULL,
{"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},
@ -1788,11 +1805,11 @@ static funcentry_T global_functions[] =
NULL
#endif
},
{"test_setmouse", 2, 2, 0, NULL,
{"test_setmouse", 2, 2, 0, arg2_number,
ret_void, f_test_setmouse},
{"test_settime", 1, 1, FEARG_1, NULL,
{"test_settime", 1, 1, FEARG_1, arg1_number,
ret_void, f_test_settime},
{"test_srand_seed", 0, 1, FEARG_1, NULL,
{"test_srand_seed", 0, 1, FEARG_1, arg1_number,
ret_void, f_test_srand_seed},
{"test_unknown", 0, 0, 0, NULL,
ret_any, f_test_unknown},
@ -1814,7 +1831,7 @@ static funcentry_T global_functions[] =
ret_string, f_toupper},
{"tr", 3, 3, FEARG_1, arg3_string,
ret_string, f_tr},
{"trim", 1, 3, FEARG_1, NULL,
{"trim", 1, 3, FEARG_1, arg3_string_string_nr,
ret_string, f_trim},
{"trunc", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_trunc)},
@ -1830,7 +1847,7 @@ static funcentry_T global_functions[] =
ret_list_any, f_uniq},
{"values", 1, 1, FEARG_1, arg1_dict,
ret_list_any, f_values},
{"virtcol", 1, 1, FEARG_1, NULL,
{"virtcol", 1, 1, FEARG_1, arg1_string_or_list,
ret_number, f_virtcol},
{"visualmode", 0, 1, 0, NULL,
ret_string, f_visualmode},
@ -2552,7 +2569,8 @@ f_charidx(typval_T *argvars, typval_T *rettv)
if (argvars[0].v_type != VAR_STRING || argvars[1].v_type != VAR_NUMBER
|| (argvars[2].v_type != VAR_UNKNOWN
&& argvars[2].v_type != VAR_NUMBER))
&& argvars[2].v_type != VAR_NUMBER
&& argvars[2].v_type != VAR_BOOL))
{
emsg(_(e_invarg));
return;
@ -9763,6 +9781,12 @@ f_trim(typval_T *argvars, typval_T *rettv)
if (head == NULL)
return;
if (argvars[1].v_type != VAR_UNKNOWN && argvars[1].v_type != VAR_STRING)
{
semsg(_(e_invarg2), tv_get_string(&argvars[1]));
return;
}
if (argvars[1].v_type == VAR_STRING)
{
mask = tv_get_string_buf_chk(&argvars[1], buf2);

View File

@ -2564,8 +2564,9 @@ eval_variable(
int ret = OK;
typval_T *tv = NULL;
int found = FALSE;
dictitem_T *v;
hashtab_T *ht = NULL;
int cc;
type_T *type = NULL;
// truncate the name, so that we can use strcmp()
cc = name[len];
@ -2575,13 +2576,16 @@ eval_variable(
if ((tv = lookup_debug_var(name)) == NULL)
{
// Check for user-defined variables.
v = find_var(name, NULL, flags & EVAL_VAR_NOAUTOLOAD);
dictitem_T *v = find_var(name, &ht, flags & EVAL_VAR_NOAUTOLOAD);
if (v != NULL)
{
tv = &v->di_tv;
if (dip != NULL)
*dip = v;
}
else
ht = NULL;
}
if (tv == NULL && (in_vim9script() || STRNCMP(name, "s:", 2) == 0))
@ -2627,6 +2631,7 @@ eval_variable(
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
+ import->imp_var_vals_idx;
tv = sv->sv_tv;
type = sv->sv_type;
}
}
else if (in_vim9script())
@ -2655,18 +2660,32 @@ eval_variable(
}
else if (rettv != NULL)
{
if (ht != NULL && ht == get_script_local_ht())
{
svar_T *sv = find_typval_in_script(tv);
if (sv != NULL)
type = sv->sv_type;
}
// If a list or dict variable wasn't initialized, do it now.
if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL)
{
tv->vval.v_dict = dict_alloc();
if (tv->vval.v_dict != NULL)
{
++tv->vval.v_dict->dv_refcount;
tv->vval.v_dict->dv_type = alloc_type(type);
}
}
else if (tv->v_type == VAR_LIST && tv->vval.v_list == NULL)
{
tv->vval.v_list = list_alloc();
if (tv->vval.v_list != NULL)
{
++tv->vval.v_list->lv_refcount;
tv->vval.v_list->lv_type = alloc_type(type);
}
}
else if (tv->v_type == VAR_BLOB && tv->vval.v_blob == NULL)
{

View File

@ -208,7 +208,7 @@ cause_errthrow(
* not skipped. Errors in those commands may affect what of the subsequent
* commands are regarded part of catch and finally clauses. Catching the
* exception would then cause execution of commands not intended by the
* user, who wouldn't even get aware of the problem. Therefor, discard the
* user, who wouldn't even get aware of the problem. Therefore, discard the
* exception currently being thrown to prevent it from being caught. Just
* execute finally clauses and terminate.
*/
@ -896,11 +896,28 @@ ex_eval(exarg_T *eap)
{
typval_T tv;
evalarg_T evalarg;
int name_only = FALSE;
char_u *p;
long lnum = SOURCING_LNUM;
if (in_vim9script())
{
char_u *alias;
p = eap->arg;
get_name_len(&p, &alias, FALSE, FALSE);
name_only = ends_excmd2(eap->arg, skipwhite(p));
vim_free(alias);
}
fill_evalarg_from_eap(&evalarg, eap, eap->skip);
if (eval0(eap->arg, &tv, eap, &evalarg) == OK)
{
clear_tv(&tv);
if (in_vim9script() && name_only && lnum == SOURCING_LNUM)
semsg(_(e_expression_without_effect_str), eap->arg);
}
clear_evalarg(&evalarg, eap);
}
@ -1225,9 +1242,14 @@ ex_while(exarg_T *eap)
}
else
{
long save_lnum = SOURCING_LNUM;
// Evaluate the argument and get the info in a structure.
fi = eval_for_line(eap->arg, &error, eap, &evalarg);
cstack->cs_forinfo[cstack->cs_idx] = fi;
// Errors should use the first line number.
SOURCING_LNUM = save_lnum;
}
// use the element at the start of the list and advance
@ -1282,7 +1304,7 @@ ex_continue(exarg_T *eap)
{
// Try to find the matching ":while". This might stop at a try
// conditional not in its finally clause (which is then to be executed
// next). Therefor, inactivate all conditionals except the ":while"
// next). Therefore, inactivate all conditionals except the ":while"
// itself (if reached).
idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
if (idx >= 0 && (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))

View File

@ -597,13 +597,17 @@ list_append(list_T *l, listitem_T *item)
/*
* Append typval_T "tv" to the end of list "l". "tv" is copied.
* Return FAIL when out of memory.
* Return FAIL when out of memory or the type is wrong.
*/
int
list_append_tv(list_T *l, typval_T *tv)
{
listitem_T *li = listitem_alloc();
listitem_T *li;
if (l->lv_type != NULL && l->lv_type->tt_member != NULL
&& check_typval_arg_type(l->lv_type->tt_member, tv, 0) == FAIL)
return FAIL;
li = listitem_alloc();
if (li == NULL)
return FAIL;
copy_tv(tv, &li->li_tv);

View File

@ -993,8 +993,12 @@ curs_columns(
if (textwidth <= 0)
{
// No room for text, put cursor in last char of window.
// If not wrapping, the last non-empty line.
curwin->w_wcol = curwin->w_width - 1;
curwin->w_wrow = curwin->w_height - 1;
if (curwin->w_p_wrap)
curwin->w_wrow = curwin->w_height - 1;
else
curwin->w_wrow = curwin->w_height - 1 - curwin->w_empty_rows;
}
else if (curwin->w_p_wrap && curwin->w_width != 0)
{

View File

@ -1230,9 +1230,10 @@ ex_set(exarg_T *eap)
*/
int
do_set(
char_u *arg, // option string (may be written to!)
char_u *arg_start, // option string (may be written to!)
int opt_flags)
{
char_u *arg = arg_start;
int opt_idx;
char *errmsg;
char errbuf[80];
@ -1357,7 +1358,22 @@ do_set(
// remember character after option name
afterchar = arg[len];
if (!in_vim9script())
if (in_vim9script())
{
char_u *p = skipwhite(arg + len);
// disallow white space before =val, +=val, -=val, ^=val
if (p > arg + len && (p[0] == '='
|| (vim_strchr((char_u *)"+-^", p[0]) != NULL
&& p[1] == '=')))
{
errmsg = e_no_white_space_allowed_between_option_and;
arg = p;
startarg = p;
goto skip;
}
}
else
// skip white space, allow ":set ai ?", ":set hlsearch !"
while (VIM_ISWHITE(arg[len]))
++len;
@ -1387,7 +1403,11 @@ do_set(
if (opt_idx == -1 && key == 0) // found a mismatch: skip
{
errmsg = N_("E518: Unknown option");
if (in_vim9script() && arg > arg_start
&& vim_strchr((char_u *)"!&<", *arg) != NULL)
errmsg = e_no_white_space_allowed_between_option_and;
else
errmsg = N_("E518: Unknown option");
goto skip;
}

View File

@ -11,6 +11,7 @@ varnumber_T tv_get_bool_chk(typval_T *varp, int *denote);
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_dict_arg(typval_T *args, int idx);
char_u *tv_get_string(typval_T *varp);
char_u *tv_get_string_strict(typval_T *varp);
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);

View File

@ -1371,8 +1371,6 @@ nfa_regatom(void)
int negated;
int result;
int startc = -1;
int endc = -1;
int oldstartc = -1;
int save_prev_at_start = prev_at_start;
c = getchr();
@ -1838,7 +1836,7 @@ collection:
* Failed to recognize a character class. Use the simple
* version that turns [abc] into 'a' OR 'b' OR 'c'
*/
startc = endc = oldstartc = -1;
startc = -1;
negated = FALSE;
if (*regparse == '^') // negated range
{
@ -1859,7 +1857,8 @@ collection:
emit_range = FALSE;
while (regparse < endp)
{
oldstartc = startc;
int oldstartc = startc;
startc = -1;
got_coll_char = FALSE;
if (*regparse == '[')
@ -2017,7 +2016,8 @@ collection:
// Previous char was '-', so this char is end of range.
if (emit_range)
{
endc = startc;
int endc = startc;
startc = oldstartc;
if (startc > endc)
EMSG_RET_FAIL(_(e_reverse_range));

View File

@ -5276,6 +5276,11 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
FILE *fd2 = NULL;
char_u *textline = NULL;
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_dict_arg(argvars, 1) == FAIL))
return;
// First open the files. If this fails bail out.
fname1 = tv_get_string_buf_chk(&argvars[0], buf1);
if (do_diff)

View File

@ -0,0 +1,10 @@
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @13||+1&&| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0|>+0#4040ff13&||+1#0000000&| +0#0000e05#a8a8a8255@2>a+0#0000000#ffffff0@2| @26
| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@16||+1&&| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@1||+1&&| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@29
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @15||+1&&| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| ||+1&&| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @28
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @10||+1&&| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0|>+0#4040ff13&||+1#0000000&| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @23
|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @3||+1#0000000&|~+0#4040ff13&| @31
|~| @18||+1#0000000&|~+0#4040ff13&| @3||+1#0000000&|~+0#4040ff13&| @31
|~| @18||+1#0000000&|~+0#4040ff13&| @3||+1#0000000&|~+0#4040ff13&| @31
|~| @18||+1#0000000&|~+0#4040ff13&| @3||+1#0000000&|~+0#4040ff13&| @31
|<+1#0000000&|a|m|e|]| |[|+|]| |1|,|1| @3|A|l@1| |<|]| |1|,| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @3|1|,|1| @9|A|l@1
| +0&&@59

View File

@ -0,0 +1,10 @@
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @13||+1&&| +0#0000e05#a8a8a8255@2|>+0#4040ff13#ffffff0||+1#0000000&| +0#0000e05#a8a8a8255@2>a+0#0000000#ffffff0@2| @27
| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@16||+1&&| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0||+1&&| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@30
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @15||+1&&| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0||+1&&| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @29
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @10||+1&&| +0#0000e05#a8a8a8255@2|>+0#4040ff13#ffffff0||+1#0000000&| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @24
|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @2||+1#0000000&|~+0#4040ff13&| @32
|~| @18||+1#0000000&|~+0#4040ff13&| @2||+1#0000000&|~+0#4040ff13&| @32
|~| @18||+1#0000000&|~+0#4040ff13&| @2||+1#0000000&|~+0#4040ff13&| @32
|~| @18||+1#0000000&|~+0#4040ff13&| @2||+1#0000000&|~+0#4040ff13&| @32
|<+1#0000000&|a|m|e|]| |[|+|]| |1|,|1| @3|A|l@1| |<| |1|,| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @3|1|,|1| @10|A|l@1
| +0&&@59

View File

@ -0,0 +1,10 @@
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @13||+1&&| +0#0000e05#a8a8a8255@2||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2>a+0#0000000#ffffff0@2| @28
| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@16||+1&&| +0#0000e05#a8a8a8255@2||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@31
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @15||+1&&| +0#0000e05#a8a8a8255@2||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @30
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @10||+1&&| +0#0000e05#a8a8a8255@2||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @25
|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @1||+1#0000000&|~+0#4040ff13&| @33
|~| @18||+1#0000000&|~+0#4040ff13&| @1||+1#0000000&|~+0#4040ff13&| @33
|~| @18||+1#0000000&|~+0#4040ff13&| @1||+1#0000000&|~+0#4040ff13&| @33
|~| @18||+1#0000000&|~+0#4040ff13&| @1||+1#0000000&|~+0#4040ff13&| @33
|<+1#0000000&|a|m|e|]| |[|+|]| |1|,|1| @3|A|l@1| |<| |1| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @4|1|,|1| @10|A|l@1
| +0&&@59

View File

@ -0,0 +1,10 @@
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @13||+1&&| +0#0000e05#a8a8a8255@1||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2>a+0#0000000#ffffff0@2| @29
| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@16||+1&&| +0#0000e05#a8a8a8255@1||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@32
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @15||+1&&| +0#0000e05#a8a8a8255@1||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @31
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @10||+1&&| +0#0000e05#a8a8a8255@1||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @26
|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| ||+1#0000000&|~+0#4040ff13&| @34
|~| @18||+1#0000000&|~+0#4040ff13&| ||+1#0000000&|~+0#4040ff13&| @34
|~| @18||+1#0000000&|~+0#4040ff13&| ||+1#0000000&|~+0#4040ff13&| @34
|~| @18||+1#0000000&|~+0#4040ff13&| ||+1#0000000&|~+0#4040ff13&| @34
|<+1#0000000&|a|m|e|]| |[|+|]| |1|,|1| @3|A|l@1| |<|1| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @4|1|,|1| @11|A|l@1
| +0&&@59

View File

@ -0,0 +1,10 @@
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @13||+1&&| +0#0000e05#a8a8a8255||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2>a+0#0000000#ffffff0@2| @30
| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@16||+1&&| +0#0000e05#a8a8a8255||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@33
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @15||+1&&| +0#0000e05#a8a8a8255||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @32
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @10||+1&&| +0#0000e05#a8a8a8255||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @27
|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&||+1#0000000&|~+0#4040ff13&| @35
|~| @18||+1#0000000&|~+0#4040ff13&||+1#0000000&|~+0#4040ff13&| @35
|~| @18||+1#0000000&|~+0#4040ff13&||+1#0000000&|~+0#4040ff13&| @35
|~| @18||+1#0000000&|~+0#4040ff13&||+1#0000000&|~+0#4040ff13&| @35
|<+1#0000000&|a|m|e|]| |[|+|]| |1|,|1| @3|A|l@1| |<| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1
| +0&&@59

View File

@ -0,0 +1,10 @@
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @13||+1&&| +0#0000e05#a8a8a8255@4||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @26
| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@16||+1&&| +0#0000e05#a8a8a8255@4||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@29
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @15||+1&&| +0#0000e05#a8a8a8255@4||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @28
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @10||+1&&| +0#0000e05#a8a8a8255@3> ||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @23
|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @3||+1#0000000&|~+0#4040ff13&| @31
|~| @18||+1#0000000&|~+0#4040ff13&| @3||+1#0000000&|~+0#4040ff13&| @31
|~| @18||+1#0000000&|~+0#4040ff13&| @3||+1#0000000&|~+0#4040ff13&| @31
|~| @18||+1#0000000&|~+0#4040ff13&| @3||+1#0000000&|~+0#4040ff13&| @31
|<+1#0000000&|a|m|e|]| |[|+|]| |1|,|1| @3|A|l@1| |<+3&&|]| |1|,| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @3|1|,|1| @9|A|l@1
|:+0&&|s|e|t| |n|o|w|r|a|p| |f|o|l|d|c|o|l|u|m|n|=|4| @35

View File

@ -0,0 +1,10 @@
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @13||+1&&| +0#0000e05#a8a8a8255||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@2| @30
| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@16||+1&&| +0#0000e05#a8a8a8255||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2| +0#0000000#ffffff0@33
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @15||+1&&| +0#0000e05#a8a8a8255||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0| @32
| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @10||+1&&> +0#0000e05#a8a8a8255||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@2|a+0#0000000#ffffff0@5| @27
|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&||+1#0000000&|~+0#4040ff13&| @35
|~| @18||+1#0000000&|~+0#4040ff13&||+1#0000000&|~+0#4040ff13&| @35
|~| @18||+1#0000000&|~+0#4040ff13&||+1#0000000&|~+0#4040ff13&| @35
|~| @18||+1#0000000&|~+0#4040ff13&||+1#0000000&|~+0#4040ff13&| @35
|<+1#0000000&|a|m|e|]| |[|+|]| |1|,|1| @3|A|l@1| |<+3&&| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1
|:+0&&|s|e|t| |n|o|w|r|a|p| |f|o|l|d|c|o|l|u|m|n|=|4| @35

View File

@ -1,6 +1,7 @@
" Test for :cd and chdir()
source shared.vim
source check.vim
func Test_cd_large_path()
" This used to crash with a heap write overflow.
@ -177,6 +178,21 @@ func Test_lcd_split()
quit!
endfunc
func Test_cd_from_non_existing_dir()
CheckNotMSWindows
let saveddir = getcwd()
call mkdir('Xdeleted_dir')
cd Xdeleted_dir
call delete(saveddir .. '/Xdeleted_dir', 'd')
" Expect E187 as the current directory was deleted.
call assert_fails('pwd', 'E187:')
call assert_equal('', getcwd())
cd -
call assert_equal(saveddir, getcwd())
endfunc
func Test_cd_completion()
call mkdir('XComplDir1', 'p')
call mkdir('XComplDir2', 'p')

View File

@ -252,6 +252,12 @@ endfunc
func Test_communicate_ipv6()
CheckIPv6
" FIXME: this test is very flaky on MS-Windows with the GUI
if has('gui_running') && has('win32')
throw 'Skipped: test is very flaky with MS-Windows in GUI'
endif
call Test_communicate()
endfunc

View File

@ -124,6 +124,7 @@ endfunc
func Test_uncrypt_xchacha20_invalid()
CheckFeature sodium
" load an invalid encrypted file and verify it can be decrypted with an
" error message
try
@ -142,6 +143,7 @@ endfunc
func Test_uncrypt_xchacha20_2()
CheckFeature sodium
sp Xcrypt_sodium.txt
" Create a larger file, so that Vim will write in several blocks
call setline(1, range(1,4000))
@ -159,7 +161,7 @@ func Test_uncrypt_xchacha20_2()
" successfully decrypted
call assert_equal(range(1, 4000)->map( {_, v -> string(v)}), getline(1,'$'))
set key=
w!
w! ++ff=unix
" enryption removed
call assert_match('"Xcrypt_sodium.txt" 4000L, 18893B written', execute(':message'))
bw!
@ -170,6 +172,7 @@ endfunc
func Test_uncrypt_xchacha20_3_persistent_undo()
CheckFeature sodium
CheckFeature persistent_undo
sp Xcrypt_sodium_undo.txt
set cryptmethod=xchacha20 undofile
call feedkeys(":X\<CR>sodium\<CR>sodium\<CR>", 'xt')
@ -191,7 +194,7 @@ func Test_uncrypt_xchacha20_3_persistent_undo()
" should fail
norm! u
call assert_match('Already at oldest change', execute(':1mess'))
call assert_fails('verbose rundo' .. fnameescape(ufile), 'E822')
call assert_fails('verbose rundo ' .. fnameescape(ufile), 'E822')
bw!
set undolevels& cryptmethod& undofile&
call delete('Xcrypt_sodium_undo.txt')

View File

@ -1,6 +1,8 @@
" Tests for 'listchars' display with 'list' and :list
source check.vim
source view_util.vim
source screendump.vim
func Test_listchars()
enew!
@ -356,4 +358,40 @@ func Test_listchars_window_local()
set list& listchars&
endfunc
func Test_listchars_foldcolumn()
CheckScreendump
let lines =<< trim END
call setline(1, ['aaa', '', 'a', 'aaaaaa'])
vsplit
vsplit
windo set signcolumn=yes foldcolumn=1 winminwidth=0 nowrap list listchars=extends:>,precedes:<
END
call writefile(lines, 'XTest_listchars')
let buf = RunVimInTerminal('-S XTest_listchars', {'rows': 10, 'cols': 60})
call term_sendkeys(buf, "13\<C-W>>")
call VerifyScreenDump(buf, 'Test_listchars_01', {})
call term_sendkeys(buf, "\<C-W>>")
call VerifyScreenDump(buf, 'Test_listchars_02', {})
call term_sendkeys(buf, "\<C-W>>")
call VerifyScreenDump(buf, 'Test_listchars_03', {})
call term_sendkeys(buf, "\<C-W>>")
call VerifyScreenDump(buf, 'Test_listchars_04', {})
call term_sendkeys(buf, "\<C-W>>")
call VerifyScreenDump(buf, 'Test_listchars_05', {})
call term_sendkeys(buf, "\<C-W>h")
call term_sendkeys(buf, ":set nowrap foldcolumn=4\<CR>")
call term_sendkeys(buf, "15\<C-W><")
call VerifyScreenDump(buf, 'Test_listchars_06', {})
call term_sendkeys(buf, "4\<C-W><")
call VerifyScreenDump(buf, 'Test_listchars_07', {})
" clean up
call StopVimInTerminal(buf)
call delete('XTest_listchars')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -373,9 +373,9 @@ func Test_searchpairpos()
endfunc
func Test_searchpair_errors()
call assert_fails("call searchpair([0], 'middle', 'end', 'bW', 'skip', 99, 100)", 'E730: using List as a String')
call assert_fails("call searchpair('start', {-> 0}, 'end', 'bW', 'skip', 99, 100)", 'E729: using Funcref as a String')
call assert_fails("call searchpair('start', 'middle', {'one': 1}, 'bW', 'skip', 99, 100)", 'E731: using Dictionary as a String')
call assert_fails("call searchpair([0], 'middle', 'end', 'bW', 'skip', 99, 100)", 'E730: Using a List as a String')
call assert_fails("call searchpair('start', {-> 0}, 'end', 'bW', 'skip', 99, 100)", 'E729: Using a Funcref as a String')
call assert_fails("call searchpair('start', 'middle', {'one': 1}, 'bW', 'skip', 99, 100)", 'E731: Using a Dictionary as a String')
call assert_fails("call searchpair('start', 'middle', 'end', 'flags', 'skip', 99, 100)", 'E475: Invalid argument: flags')
call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', -99, 100)", 'E475: Invalid argument: -99')
call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', 99, -100)", 'E475: Invalid argument: -100')
@ -384,9 +384,9 @@ func Test_searchpair_errors()
endfunc
func Test_searchpairpos_errors()
call assert_fails("call searchpairpos([0], 'middle', 'end', 'bW', 'skip', 99, 100)", 'E730: using List as a String')
call assert_fails("call searchpairpos('start', {-> 0}, 'end', 'bW', 'skip', 99, 100)", 'E729: using Funcref as a String')
call assert_fails("call searchpairpos('start', 'middle', {'one': 1}, 'bW', 'skip', 99, 100)", 'E731: using Dictionary as a String')
call assert_fails("call searchpairpos([0], 'middle', 'end', 'bW', 'skip', 99, 100)", 'E730: Using a List as a String')
call assert_fails("call searchpairpos('start', {-> 0}, 'end', 'bW', 'skip', 99, 100)", 'E729: Using a Funcref as a String')
call assert_fails("call searchpairpos('start', 'middle', {'one': 1}, 'bW', 'skip', 99, 100)", 'E731: Using a Dictionary as a String')
call assert_fails("call searchpairpos('start', 'middle', 'end', 'flags', 'skip', 99, 100)", 'E475: Invalid argument: flags')
call assert_fails("call searchpairpos('start', 'middle', 'end', 'bW', 'func', -99, 100)", 'E475: Invalid argument: -99')
call assert_fails("call searchpairpos('start', 'middle', 'end', 'bW', 'func', 99, -100)", 'E475: Invalid argument: -100')

View File

@ -574,4 +574,8 @@ func Test_swapchoice()
augroup! test_swapchoice
endfunc
func Test_no_swap_file()
call assert_equal("\nNo swap file", execute('swapname'))
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -1340,7 +1340,7 @@ endfunc
func Test_prop_func_invalid_args()
call assert_fails('call prop_clear(1, 2, [])', 'E715:')
call assert_fails('call prop_clear(-1, 2)', 'E16:')
call assert_fails('call prop_find(test_null_dict())', 'E474:')
call assert_fails('call prop_find(test_null_dict())', 'E715:')
call assert_fails('call prop_find({"bufnr" : []})', 'E730:')
call assert_fails('call prop_find({})', 'E968:')
call assert_fails('call prop_find({}, "x")', 'E474:')

View File

@ -104,6 +104,20 @@ def Test_add_list()
add(l, 123)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
var l: list<string> = ['a']
l->add(123)
END
CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3)
lines =<< trim END
vim9script
var l: list<string>
l->add(123)
END
CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3)
enddef
def Test_add_blob()
@ -142,8 +156,8 @@ def Test_add_blob()
enddef
def Test_and()
CheckDefFailure(['echo and("x", 0x2)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo and(0x1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
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')
enddef
def Test_append()
@ -161,19 +175,42 @@ def Test_append()
enddef
def Test_argc()
CheckDefFailure(['echo argc("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['argc("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_arglistid()
CheckDefFailure(['echo arglistid("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo arglistid(1, "y")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['echo arglistid("x", "y")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['arglistid("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['arglistid(1, "y")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['arglistid("x", "y")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_argv()
CheckDefFailure(['echo argv("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo argv(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['echo argv("x", "y")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['argv("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['argv(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['argv("x", "y")'], 'E1013: Argument 1: type mismatch, expected number but got string')
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')
CheckDefFailure(['assert_equalfile("f1", "f2", ["a"])'], 'E1013: Argument 3: type mismatch, expected string but got list<string>')
enddef
def Test_assert_exception()
CheckDefFailure(['assert_exception({})'], 'E1013: Argument 1: type mismatch, expected string but got dict<unknown>')
CheckDefFailure(['assert_exception("E1:", v:null)'], 'E1013: Argument 2: type mismatch, expected string but got special')
enddef
def Test_assert_match()
CheckDefFailure(['assert_match({}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<unknown>')
CheckDefFailure(['assert_match("a", 1)'], 'E1013: Argument 2: type mismatch, expected string but got number')
CheckDefFailure(['assert_match("a", "b", null)'], 'E1013: Argument 3: type mismatch, expected string but got special')
enddef
def Test_assert_notmatch()
CheckDefFailure(['assert_notmatch({}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<unknown>')
CheckDefFailure(['assert_notmatch("a", 1)'], 'E1013: Argument 2: type mismatch, expected string but got number')
CheckDefFailure(['assert_notmatch("a", "b", null)'], 'E1013: Argument 3: type mismatch, expected string but got special')
enddef
def Test_balloon_show()
@ -208,6 +245,11 @@ def Test_browse()
CheckDefExecAndScriptFailure(lines, 'E1174: String required for argument 4')
enddef
def Test_browsedir()
CheckDefFailure(['browsedir({}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<unknown>')
CheckDefFailure(['browsedir("a", [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>')
enddef
def Test_bufadd()
assert_fails('bufadd([])', 'E730:')
enddef
@ -285,12 +327,51 @@ def Test_call_call()
l->assert_equal([1, 2, 3])
enddef
def Test_ch_canread()
if !has('channel')
CheckFeature channel
endif
CheckDefFailure(['ch_canread(10)'], 'E1013: Argument 1: type mismatch, expected channel but got number')
enddef
def Test_ch_close()
if !has('channel')
CheckFeature channel
endif
CheckDefFailure(['ch_close("c")'], 'E1013: Argument 1: type mismatch, expected channel but got string')
enddef
def Test_ch_close_in()
if !has('channel')
CheckFeature channel
endif
CheckDefFailure(['ch_close_in(true)'], 'E1013: Argument 1: type mismatch, expected channel but got bool')
enddef
def Test_ch_info()
if !has('channel')
CheckFeature channel
endif
CheckDefFailure(['ch_info([1])'], 'E1013: Argument 1: type mismatch, expected channel but got list<number>')
enddef
def Test_ch_logfile()
if !has('channel')
CheckFeature channel
endif
assert_fails('ch_logfile(true)', 'E1174:')
assert_fails('ch_logfile("foo", true)', 'E1174:')
CheckDefAndScriptFailure2(['ch_logfile(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
CheckDefAndScriptFailure2(['ch_logfile("a", true)'], 'E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2')
enddef
def Test_ch_open()
if !has('channel')
CheckFeature channel
endif
CheckDefAndScriptFailure2(['ch_open({"a": 10}, "a")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1')
CheckDefAndScriptFailure2(['ch_open("a", [1])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2')
enddef
def Test_char2nr()
@ -303,6 +384,17 @@ def Test_charclass()
assert_fails('charclass(true)', 'E1174:')
enddef
def Test_charcol()
CheckDefFailure(['charcol(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['charcol({a: 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>')
enddef
def Test_charidx()
CheckDefFailure(['charidx("a", "b")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['charidx(0z10, 1)'], 'E1013: Argument 1: type mismatch, expected string but got blob')
CheckDefFailure(['charidx("a", 1, "")'], 'E1013: Argument 3: type mismatch, expected bool but got string')
enddef
def Test_chdir()
assert_fails('chdir(true)', 'E1174:')
enddef
@ -315,7 +407,7 @@ def Test_cindent()
enddef
def Test_clearmatches()
CheckDefFailure(['echo clearmatches("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['clearmatches("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_col()
@ -324,6 +416,11 @@ def Test_col()
col([1, '$'])->assert_equal(5)
assert_fails('col(true)', 'E1174:')
CheckDefFailure(['col(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['col({a: 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>')
CheckDefFailure(['col(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool')
bw!
enddef
def Test_confirm()
@ -382,12 +479,15 @@ enddef
def Test_debugbreak()
CheckMSWindows
CheckDefFailure(['echo debugbreak("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['debugbreak("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_delete()
var res: bool = delete('doesnotexist')
assert_equal(true, res)
CheckDefFailure(['delete(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['delete("a", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number')
enddef
def Test_diff_filler()
@ -424,10 +524,10 @@ def Test_execute()
res = execute(["echo 'here'", "echo 'there'"])
assert_equal("\nhere\nthere", res)
CheckDefFailure(['echo execute(123)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['echo execute([123])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>')
CheckDefFailure(['execute(123)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['execute([123])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>')
CheckDefExecFailure(['echo execute(["xx", 123])'], 'E492')
CheckDefFailure(['echo execute("xx", 123)'], 'E1013: Argument 2: type mismatch, expected string but got number')
CheckDefFailure(['execute("xx", 123)'], 'E1013: Argument 2: type mismatch, expected string but got number')
enddef
def Test_exepath()
@ -586,6 +686,26 @@ def Test_feedkeys()
unlet g:TestVar
enddef
def Test_indent()
CheckDefAndScriptFailure2(['indent([1])'], 'E1013: Argument 1: type mismatch, expected string but got list<number>', '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<string>', '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<string>', '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)
@ -613,15 +733,19 @@ def Test_filewritable()
enddef
def Test_finddir()
CheckDefExecFailure(['echo finddir(true)'], 'E1174:')
CheckDefExecFailure(['echo finddir(v:null)'], 'E1174:')
CheckDefAndScriptFailure2(['finddir(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1')
CheckDefAndScriptFailure2(['finddir(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1')
CheckDefExecFailure(['echo finddir("")'], 'E1175:')
CheckDefAndScriptFailure2(['finddir("a", [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>', 'E730: Using a List as a String')
CheckDefAndScriptFailure2(['finddir("a", "b", "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_findfile()
CheckDefExecFailure(['echo findfile(true)'], 'E1174:')
CheckDefExecFailure(['echo findfile(v:null)'], 'E1174:')
CheckDefExecFailure(['echo findfile("")'], 'E1175:')
CheckDefExecFailure(['findfile(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool')
CheckDefExecFailure(['findfile(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special')
CheckDefExecFailure(['findfile("")'], 'E1175:')
CheckDefAndScriptFailure2(['findfile("a", [])'], 'E1013: Argument 2: type mismatch, expected string but got list<unknown>', 'E730: Using a List as a String')
CheckDefAndScriptFailure2(['findfile("a", "b", "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_flattennew()
@ -646,57 +770,57 @@ def Test_float_funcs_args()
CheckFeature float
# acos()
CheckDefFailure(['echo acos("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['acos("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# asin()
CheckDefFailure(['echo asin("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['asin("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# atan()
CheckDefFailure(['echo atan("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['atan("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# atan2()
CheckDefFailure(['echo atan2("a", 1.1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo atan2(1.2, "a")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['echo atan2(1.2)'], 'E119:')
CheckDefFailure(['atan2("a", 1.1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['atan2(1.2, "a")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['atan2(1.2)'], 'E119:')
# ceil()
CheckDefFailure(['echo ceil("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['ceil("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# cos()
CheckDefFailure(['echo cos("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['cos("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# cosh()
CheckDefFailure(['echo cosh("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['cosh("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# exp()
CheckDefFailure(['echo exp("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['exp("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# float2nr()
CheckDefFailure(['echo float2nr("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['float2nr("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# floor()
CheckDefFailure(['echo floor("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['floor("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# fmod()
CheckDefFailure(['echo fmod(1.1, "a")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['echo fmod("a", 1.1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo fmod(1.1)'], 'E119:')
CheckDefFailure(['fmod(1.1, "a")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['fmod("a", 1.1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['fmod(1.1)'], 'E119:')
# isinf()
CheckDefFailure(['echo isinf("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['isinf("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# isnan()
CheckDefFailure(['echo isnan("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['isnan("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# log()
CheckDefFailure(['echo log("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['log("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# log10()
CheckDefFailure(['echo log10("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['log10("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# pow()
CheckDefFailure(['echo pow("a", 1.1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo pow(1.1, "a")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['echo pow(1.1)'], 'E119:')
CheckDefFailure(['pow("a", 1.1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['pow(1.1, "a")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['pow(1.1)'], 'E119:')
# round()
CheckDefFailure(['echo round("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['round("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# sin()
CheckDefFailure(['echo sin("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['sin("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# sinh()
CheckDefFailure(['echo sinh("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['sinh("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# sqrt()
CheckDefFailure(['echo sqrt("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['sqrt("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# tan()
CheckDefFailure(['echo tan("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['tan("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# tanh()
CheckDefFailure(['echo tanh("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['tanh("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
# trunc()
CheckDefFailure(['echo trunc("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['trunc("a")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_fnameescape()
@ -849,17 +973,17 @@ def Test_getcompletion()
enddef
def Test_getcurpos()
CheckDefFailure(['echo getcursorcharpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getcursorcharpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_getcursorcharpos()
CheckDefFailure(['echo getcursorcharpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getcursorcharpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_getcwd()
CheckDefFailure(['echo getcwd("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo getcwd("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo getcwd(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['getcwd("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getcwd("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getcwd(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
enddef
def Test_getloclist_return_type()
@ -907,9 +1031,9 @@ def Test_getftype()
enddef
def Test_getjumplist()
CheckDefFailure(['echo getjumplist("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo getjumplist("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo getjumplist(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['getjumplist("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getjumplist("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getjumplist(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
enddef
def Test_getmarklist()
@ -919,7 +1043,7 @@ def Test_getmarklist()
enddef
def Test_getmatches()
CheckDefFailure(['echo getmatches("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getmatches("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_getpos()
@ -969,11 +1093,11 @@ def Test_getregtype()
enddef
def Test_gettabinfo()
CheckDefFailure(['echo gettabinfo("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['gettabinfo("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_gettagstack()
CheckDefFailure(['echo gettagstack("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['gettagstack("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_gettext()
@ -982,11 +1106,11 @@ def Test_gettext()
enddef
def Test_getwininfo()
CheckDefFailure(['echo getwininfo("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getwininfo("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_getwinpos()
CheckDefFailure(['echo getwinpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['getwinpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_glob()
@ -1006,10 +1130,15 @@ def Test_has()
has('eval', true)->assert_equal(1)
enddef
def Test_has_key()
CheckDefAndScriptFailure2(['has_key([1, 2], "k")'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')
CheckDefAndScriptFailure2(['has_key({"a": 10}, ["a"])'], 'E1013: Argument 2: type mismatch, expected string but got list<string>', 'E730: Using a List as a String')
enddef
def Test_haslocaldir()
CheckDefFailure(['echo haslocaldir("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo haslocaldir("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo haslocaldir(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['haslocaldir("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['haslocaldir("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['haslocaldir(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
enddef
def Test_hasmapto()
@ -1110,7 +1239,7 @@ def Test_insert()
enddef
def Test_invert()
CheckDefFailure(['echo invert("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['invert("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_isdirectory()
@ -1173,8 +1302,12 @@ def SID(): number
->str2nr()
enddef
def Test_listener_flush()
CheckDefAndScriptFailure2(['listener_flush([1])'], 'E1013: Argument 1: type mismatch, expected string but got list<number>', 'E730: Using a List as a String')
enddef
def Test_listener_remove()
CheckDefFailure(['echo listener_remove("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefAndScriptFailure2(['listener_remove("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_map_function_arg()
@ -1280,13 +1413,13 @@ def Test_map_failure()
enddef
def Test_matcharg()
CheckDefFailure(['echo matcharg("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['matcharg("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_matchdelete()
CheckDefFailure(['echo matchdelete("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo matchdelete("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo matchdelete(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['matchdelete("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['matchdelete("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['matchdelete(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
enddef
def Test_max()
@ -1324,6 +1457,13 @@ def Test_min()
assert_equal([4, 5], l2)
enddef
def Test_mkdir()
CheckDefAndScriptFailure2(['mkdir(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list<string>', 'E730: Using a List as a String')
CheckDefAndScriptFailure2(['mkdir("a", {})'], 'E1013: Argument 2: type mismatch, expected string but got dict<unknown>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['mkdir("a", "b", "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
delete('a', 'rf')
enddef
def Test_nextnonblank()
CheckDefFailure(['nextnonblank(null)'], 'E1013: Argument 1: type mismatch, expected string but got special')
assert_equal(0, nextnonblank(1))
@ -1334,8 +1474,13 @@ def Test_nr2char()
enddef
def Test_or()
CheckDefFailure(['echo or("x", 0x2)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo or(0x1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['or("x", 0x2)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['or(0x1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
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')
enddef
def Test_prevnonblank()
@ -1350,6 +1495,34 @@ def Test_prompt_getprompt()
endif
enddef
def Test_prop_find()
CheckDefAndScriptFailure2(['prop_find([1, 2])'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')
CheckDefAndScriptFailure2(['prop_find([1, 2], "k")'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')
CheckDefAndScriptFailure2(['prop_find({"a": 10}, ["a"])'], 'E1013: Argument 2: type mismatch, expected string but got list<string>', 'E730: Using a List as a String')
enddef
def Test_prop_type_add()
CheckDefAndScriptFailure2(['prop_type_add({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['prop_type_add("a", "b")'], 'E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E715: Dictionary required')
enddef
def Test_prop_type_change()
CheckDefAndScriptFailure2(['prop_type_change({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['prop_type_change("a", "b")'], 'E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E715: Dictionary required')
enddef
def Test_prop_type_delete()
CheckDefAndScriptFailure2(['prop_type_delete({"a": 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['prop_type_delete({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['prop_type_delete("a", "b")'], 'E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E715: Dictionary required')
enddef
def Test_prop_type_get()
CheckDefAndScriptFailure2(['prop_type_get({"a": 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['prop_type_get({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['prop_type_get("a", "b")'], 'E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E715: Dictionary required')
enddef
def Test_rand()
CheckDefFailure(['rand(10)'], 'E1013: Argument 1: type mismatch, expected list<number> but got number')
CheckDefFailure(['rand(["a"])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<string>')
@ -1357,6 +1530,12 @@ def Test_rand()
assert_true(rand(srand()) >= 0)
enddef
def Test_range()
CheckDefAndScriptFailure2(['range("a")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
CheckDefAndScriptFailure2(['range(10, "b")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
CheckDefAndScriptFailure2(['range(10, 20, "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_readdir()
eval expand('sautest')->readdir((e) => e[0] !=# '.')
eval expand('sautest')->readdirex((e) => e.name[0] !=# '.')
@ -1386,6 +1565,9 @@ def Test_readfile()
END
CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected dict<string> but got list<string>', 1)
delete('Xreadfile')
CheckDefAndScriptFailure2(['readfile("a", 0z10)'], 'E1013: Argument 2: type mismatch, expected string but got blob', 'E976: Using a Blob as a String')
CheckDefAndScriptFailure2(['readfile("a", "b", "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_reltime()
@ -1421,7 +1603,16 @@ def Test_remote_foreground()
assert_fails('remote_foreground("NonExistingServer")', 'E241:')
enddef
def Test_remote_peek()
CheckFeature clientserver
CheckEnv DISPLAY
CheckDefAndScriptFailure2(['remote_peek(0z10)'], 'E1013: Argument 1: type mismatch, expected string but got blob', 'E976: Using a Blob as a String')
CheckDefAndScriptFailure2(['remote_peek("a5b6c7", [1])'], 'E1013: Argument 2: type mismatch, expected string but got list<number>', 'E573: Invalid server id used')
enddef
def Test_remote_startserver()
CheckFeature clientserver
CheckEnv DISPLAY
CheckDefFailure(['remote_startserver({})'], 'E1013: Argument 1: type mismatch, expected string but got dict<unknown>')
enddef
@ -1444,6 +1635,11 @@ def Test_resolve()
assert_equal('SomeFile', resolve('SomeFile'))
enddef
def Test_reverse()
CheckDefAndScriptFailure2(['reverse(10)'], 'E1013: Argument 1: type mismatch, expected list<any> but got number', 'E899: Argument of reverse() must be a List or Blob')
CheckDefAndScriptFailure2(['reverse("abc")'], 'E1013: Argument 1: type mismatch, expected list<any> but got string', 'E899: Argument of reverse() must be a List or Blob')
enddef
def Test_reverse_return_type()
var l = reverse([1, 2, 3])
var res = 0
@ -1454,18 +1650,18 @@ def Test_reverse_return_type()
enddef
def Test_screenattr()
CheckDefFailure(['echo screenattr("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo screenattr(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
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')
enddef
def Test_screenchar()
CheckDefFailure(['echo screenchar("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo screenchar(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['screenchar("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['screenchar(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
enddef
def Test_screenchars()
CheckDefFailure(['echo screenchars("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo screenchars(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['screenchars("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['screenchars(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
enddef
def Test_screenpos()
@ -1476,8 +1672,8 @@ def Test_screenpos()
enddef
def Test_screenstring()
CheckDefFailure(['echo screenstring("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo screenstring(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefFailure(['screenstring("x", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['screenstring(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
enddef
def Test_search()
@ -1563,6 +1759,13 @@ def Test_searchpair()
bwipe!
enddef
def Test_server2client()
CheckFeature clientserver
CheckEnv DISPLAY
CheckDefAndScriptFailure2(['server2client(10, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E573: Invalid server id used:')
CheckDefAndScriptFailure2(['server2client("a", 10)'], 'E1013: Argument 2: type mismatch, expected string but got number', 'E573: Invalid server id used:')
enddef
def Test_set_get_bufline()
# similar to Test_setbufline_getbufline()
var lines =<< trim END
@ -1651,7 +1854,7 @@ def Test_setcharsearch()
enddef
def Test_setcmdpos()
CheckDefFailure(['echo setcmdpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['setcmdpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_setfperm()
@ -1681,7 +1884,24 @@ def Test_sha256()
enddef
def Test_shiftwidth()
CheckDefFailure(['echo shiftwidth("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['shiftwidth("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
def Test_sign_define()
CheckDefAndScriptFailure2(['sign_define({"a": 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['sign_define({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['sign_define("a", ["b"])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E715: Dictionary required')
enddef
def Test_sign_undefine()
CheckDefAndScriptFailure2(['sign_undefine({})'], 'E1013: Argument 1: type mismatch, expected string but got dict<unknown>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['sign_undefine([1])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>', 'E155: Unknown sign:')
enddef
def Test_sign_unplace()
CheckDefAndScriptFailure2(['sign_unplace({"a": 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E474: Invalid argument')
CheckDefAndScriptFailure2(['sign_unplace({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E474: Invalid argument')
CheckDefAndScriptFailure2(['sign_unplace("a", ["b"])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E715: Dictionary required')
enddef
def Test_simplify()
@ -1776,7 +1996,7 @@ def Run_str2float()
str2float("1.00")->assert_equal(1.00)
str2float("2e-2")->assert_equal(0.02)
CheckDefFailure(['echo str2float(123)'], 'E1013:')
CheckDefFailure(['str2float(123)'], 'E1013:')
CheckScriptFailure(['vim9script', 'echo str2float(123)'], 'E1024:')
endif
enddef
@ -1784,11 +2004,11 @@ enddef
def Test_str2nr()
str2nr("1'000'000", 10, true)->assert_equal(1000000)
CheckDefFailure(['echo str2nr(123)'], 'E1013:')
CheckDefFailure(['str2nr(123)'], 'E1013:')
CheckScriptFailure(['vim9script', 'echo str2nr(123)'], 'E1024:')
CheckDefFailure(['echo str2nr("123", "x")'], 'E1013:')
CheckDefFailure(['str2nr("123", "x")'], 'E1013:')
CheckScriptFailure(['vim9script', 'echo str2nr("123", "x")'], 'E1030:')
CheckDefFailure(['echo str2nr("123", 10, "x")'], 'E1013:')
CheckDefFailure(['str2nr("123", 10, "x")'], 'E1013:')
CheckScriptFailure(['vim9script', 'echo str2nr("123", 10, "x")'], 'E1135:')
enddef
@ -1796,6 +2016,12 @@ def Test_strchars()
strchars("A\u20dd", true)->assert_equal(1)
enddef
def Test_stridx()
CheckDefAndScriptFailure2(['stridx([1], "b")'], 'E1013: Argument 1: type mismatch, expected string but got list<number>', 'E730: Using a List as a String')
CheckDefAndScriptFailure2(['stridx("a", {})'], 'E1013: Argument 2: type mismatch, expected string but got dict<unknown>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['stridx("a", "b", "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_strlen()
CheckDefFailure(['strlen([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>')
"abc"->strlen()->assert_equal(3)
@ -1812,6 +2038,12 @@ def Test_strptime()
#assert_true(strptime('%Y', '2021') != 0)
enddef
def Test_strridx()
CheckDefAndScriptFailure2(['strridx([1], "b")'], 'E1013: Argument 1: type mismatch, expected string but got list<number>', 'E730: Using a List as a String')
CheckDefAndScriptFailure2(['strridx("a", {})'], 'E1013: Argument 2: type mismatch, expected string but got dict<unknown>', 'E731: Using a Dictionary as a String')
CheckDefAndScriptFailure2(['strridx("a", "b", "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_strtrans()
CheckDefFailure(['strtrans(20)'], 'E1013: Argument 1: type mismatch, expected string but got number')
assert_equal('abc', strtrans('abc'))
@ -1869,11 +2101,63 @@ def Test_tabpagebuflist()
enddef
def Test_tabpagenr()
CheckDefFailure(['tabpagenr(1)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefAndScriptFailure2(['tabpagenr(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E15: Invalid expression:')
assert_equal(1, tabpagenr('$'))
assert_equal(1, tabpagenr())
enddef
def Test_taglist()
CheckDefAndScriptFailure2(['taglist([1])'], 'E1013: Argument 1: type mismatch, expected string but got list<number>', 'E730: Using a List as a String')
CheckDefAndScriptFailure2(['taglist("a", [2])'], 'E1013: Argument 2: type mismatch, expected string but got list<number>', 'E730: Using a List as a String')
enddef
def Test_term_dumpload()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_dumpload({"a": 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1')
CheckDefAndScriptFailure2(['term_dumpload({"a": 10}, "b")'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1')
CheckDefAndScriptFailure2(['term_dumpload("a", ["b"])'], 'E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2')
enddef
def Test_term_getaltscreen()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_getaltscreen(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1138: Using a Bool as a Number')
enddef
def Test_term_getansicolors()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_getansicolors(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list<string>', 'E745: Using a List as a Number')
enddef
def Test_term_getcursor()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_getcursor({"a": 10})'], 'E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E728: Using a Dictionary as a Number')
enddef
def Test_term_getjob()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_getjob(0z10)'], 'E1013: Argument 1: type mismatch, expected string but got blob', 'E974: Using a Blob as a Number')
enddef
def Test_term_getscrolled()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_getscrolled(1.1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E805: Using a Float as a Number')
enddef
def Test_term_getsize()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_getsize(1.1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E805: Using a Float as a Number')
enddef
def Test_term_getstatus()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_getstatus(1.1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E805: Using a Float as a Number')
enddef
def Test_term_gettitle()
CheckRunVimInTerminal
CheckDefAndScriptFailure2(['term_gettitle(1.1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E805: Using a Float as a Number')
enddef
def Test_term_gettty()
if !has('terminal')
MissingFeature 'terminal'
@ -1896,6 +2180,44 @@ def Test_term_start()
endif
enddef
def Test_test_alloc_fail()
CheckDefAndScriptFailure2(['test_alloc_fail("a", 10, 20)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E474: Invalid argument')
CheckDefAndScriptFailure2(['test_alloc_fail(10, "b", 20)'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E474: Invalid argument')
CheckDefAndScriptFailure2(['test_alloc_fail(10, 20, "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E474: Invalid argument')
enddef
def Test_test_feedinput()
CheckDefAndScriptFailure2(['test_feedinput(test_void())'], 'E1013: Argument 1: type mismatch, expected string but got void', 'E1031: Cannot use void value')
CheckDefAndScriptFailure2(['test_feedinput(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list<string>', 'E730: Using a List as a String')
enddef
def Test_test_getvalue()
CheckDefAndScriptFailure2(['test_getvalue(1.1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E474: Invalid argument')
enddef
def Test_test_ignore_error()
CheckDefAndScriptFailure2(['test_ignore_error([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E474: Invalid argument')
test_ignore_error('RESET')
enddef
def Test_test_option_not_set()
CheckDefAndScriptFailure2(['test_option_not_set([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 'E474: Invalid argument')
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')
enddef
def Test_test_settime()
CheckDefAndScriptFailure2(['test_settime([1])'], 'E1013: Argument 1: type mismatch, expected number but got list<number>', 'E745: Using a List as a Number')
enddef
def Test_test_srand_seed()
CheckDefAndScriptFailure2(['test_srand_seed([1])'], 'E1013: Argument 1: type mismatch, expected number but got list<number>', 'E745: Using a List as a Number')
CheckDefAndScriptFailure2(['test_srand_seed("10")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_timer_info()
CheckDefFailure(['timer_info("id")'], 'E1013: Argument 1: type mismatch, expected number but got string')
assert_equal([], timer_info(100))
@ -1916,17 +2238,29 @@ def Test_timer_stop()
enddef
def Test_tolower()
CheckDefFailure(['echo tolower(1)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['tolower(1)'], 'E1013: Argument 1: type mismatch, expected string but got number')
enddef
def Test_toupper()
CheckDefFailure(['echo toupper(1)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['toupper(1)'], 'E1013: Argument 1: type mismatch, expected string but got number')
enddef
def Test_tr()
CheckDefFailure(['echo tr(1, "a", "b")'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['echo tr("a", 1, "b")'], 'E1013: Argument 2: type mismatch, expected string but got number')
CheckDefFailure(['echo tr("a", "a", 1)'], 'E1013: Argument 3: type mismatch, expected string but got number')
CheckDefFailure(['tr(1, "a", "b")'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['tr("a", 1, "b")'], 'E1013: Argument 2: type mismatch, expected string but got number')
CheckDefFailure(['tr("a", "a", 1)'], 'E1013: Argument 3: type mismatch, expected string but got number')
enddef
def Test_trim()
CheckDefAndScriptFailure2(['trim(["a"])'], 'E1013: Argument 1: type mismatch, expected string but got list<string>', 'E730: Using a List as a String')
CheckDefAndScriptFailure2(['trim("a", ["b"])'], 'E1013: Argument 2: type mismatch, expected string but got list<string>', 'E730: Using a List as a String')
CheckDefAndScriptFailure2(['trim("a", "b", "c")'], 'E1013: Argument 3: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_typename()
if has('float')
assert_equal('func([unknown], [unknown]): float', typename(function('pow')))
endif
enddef
def Test_undofile()
@ -1940,6 +2274,10 @@ def Test_values()
assert_equal(['sun'], {star: 'sun'}->values())
enddef
def Test_virtcol()
CheckDefAndScriptFailure2(['virtcol(1.1)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1')
enddef
def Test_win_execute()
assert_equal("\n" .. winnr(), win_execute(win_getid(), 'echo winnr()'))
assert_equal('', win_execute(342343, 'echo winnr()'))
@ -1996,44 +2334,44 @@ def Test_winsaveview()
enddef
def Test_win_gettype()
CheckDefFailure(['echo win_gettype("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
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()
CheckDefFailure(['echo win_gotoid("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
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()
CheckDefFailure(['echo win_id2tabwin("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
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()
CheckDefFailure(['echo win_id2win("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
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()
CheckDefFailure(['echo win_screenpos("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
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()
CheckDefFailure(['echo winbufnr("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefAndScriptFailure2(['winbufnr("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_winheight()
CheckDefFailure(['echo winheight("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefAndScriptFailure2(['winheight("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_winlayout()
CheckDefFailure(['echo winlayout("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefAndScriptFailure2(['winlayout("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_winwidth()
CheckDefFailure(['echo winwidth("x")'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefAndScriptFailure2(['winwidth("x")'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
def Test_xor()
CheckDefFailure(['echo xor("x", 0x2)'], 'E1013: Argument 1: type mismatch, expected number but got string')
CheckDefFailure(['echo xor(0x1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
CheckDefAndScriptFailure2(['xor("x", 0x2)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
CheckDefAndScriptFailure2(['xor(0x1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string', 'E1030: Using a String as a Number')
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

View File

@ -647,7 +647,7 @@ def Test_expr4_equal()
CheckDefFailure(["var x = 'a' == "], 'E1097:', 3)
CheckScriptFailure(['vim9script', "var x = 'a' == "], 'E15:', 2)
CheckDefExecAndScriptFailure2(['var items: any', 'eval 1', 'eval 2', 'if items == []', 'endif'], 'E691:', 'E1072:', 4)
CheckDefExecAndScriptFailure2(['var items: any', 'eval 1 + 1', 'eval 2 + 2', 'if items == []', 'endif'], 'E691:', 'E1072:', 4)
CheckDefExecAndScriptFailure(['var x: any = "a"', 'echo x == true'], 'E1072: Cannot compare string with bool', 2)
CheckDefExecAndScriptFailure(["var x: any = true", 'echo x == ""'], 'E1072: Cannot compare bool with string', 2)

View File

@ -2538,7 +2538,7 @@ def Test_restore_modifiers()
set eventignore=
autocmd QuickFixCmdPost * copen
def AutocmdsDisabled()
eval 0
eval 1 + 2
enddef
func Func()
noautocmd call s:AutocmdsDisabled()
@ -2551,8 +2551,8 @@ def Test_restore_modifiers()
enddef
def StackTop()
eval 1
eval 2
eval 1 + 2
eval 2 + 3
# call not on fourth line
StackBot()
enddef

View File

@ -691,7 +691,7 @@ enddef
def Test_cnext_works_in_catch()
var lines =<< trim END
vim9script
au BufEnter * eval 0
au BufEnter * eval 1 + 2
writefile(['text'], 'Xfile1')
writefile(['text'], 'Xfile2')
var items = [
@ -1391,6 +1391,7 @@ def Test_import_as()
vim9script
export var one = 1
export var yes = 'yes'
export var slist: list<string>
END
writefile(export_lines, 'XexportAs')
@ -1415,6 +1416,13 @@ def Test_import_as()
END
CheckScriptSuccess(import_lines)
import_lines =<< trim END
vim9script
import {slist as impSlist} from './XexportAs'
impSlist->add(123)
END
CheckScriptFailure(import_lines, 'E1012: Type mismatch; expected string but got number')
delete('XexportAs')
enddef
@ -1746,6 +1754,21 @@ def Test_script_var_shadows_function()
CheckScriptFailure(lines, 'E1041:', 5)
enddef
def Test_script_var_shadows_command()
var lines =<< trim END
var undo = 1
undo = 2
assert_equal(2, undo)
END
CheckDefAndScriptSuccess(lines)
lines =<< trim END
var undo = 1
undo
END
CheckDefAndScriptFailure(lines, 'E1207:', 2)
enddef
def s:RetSome(): string
return 'some'
enddef
@ -1947,7 +1970,7 @@ def Test_import_rtp()
'g:imported_rtp = exported',
]
writefile(import_lines, 'Ximport_rtp.vim')
mkdir('import')
mkdir('import', 'p')
writefile(s:export_script_lines, 'import/Xexport_rtp.vim')
var save_rtp = &rtp
@ -2262,7 +2285,7 @@ def Test_if_const_expr()
assert_equal(false, res)
# with constant "false" expression may be invalid so long as the syntax is OK
if false | eval 0 | endif
if false | eval 1 + 2 | endif
if false | eval burp + 234 | endif
if false | echo burp 234 'asd' | endif
if false
@ -2488,6 +2511,12 @@ def Test_for_loop()
endfor
assert_equal('foobar', chars)
chars = ''
for x: string in {a: 'a', b: 'b'}->values()
chars ..= x
endfor
assert_equal('ab', chars)
# unpack with type
var res = ''
for [n: number, s: string] in [[1, 'a'], [2, 'b']]
@ -2539,6 +2568,7 @@ def Test_for_loop_fails()
CheckDefAndScriptFailure(['for # in range(5)'], 'E690:')
CheckDefAndScriptFailure(['for i In range(5)'], 'E690:')
CheckDefAndScriptFailure2(['var x = 5', 'for x in range(5)', 'endfor'], 'E1017:', 'E1041:')
CheckScriptFailure(['vim9script', 'var x = 5', 'for x in range(5)', '# comment', 'endfor'], 'E1041:', 3)
CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:')
delfunc! g:Func
CheckDefFailure(['for i in xxx'], 'E1001:')
@ -4069,24 +4099,72 @@ def Test_mapping_line_number()
delfunc g:FuncA
enddef
def Test_option_set()
# legacy script allows for white space
var lines =<< trim END
set foldlevel =11
call assert_equal(11, &foldlevel)
END
CheckScriptSuccess(lines)
set foldlevel
set foldlevel=12
assert_equal(12, &foldlevel)
set foldlevel+=2
assert_equal(14, &foldlevel)
set foldlevel-=3
assert_equal(11, &foldlevel)
lines =<< trim END
set foldlevel =1
END
CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: =1')
lines =<< trim END
set foldlevel +=1
END
CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: +=1')
lines =<< trim END
set foldlevel ^=1
END
CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: ^=1')
lines =<< trim END
set foldlevel -=1
END
CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: -=1')
set foldlevel&
enddef
def Test_option_modifier()
# legacy script allows for white space
var lines =<< trim END
set hlsearch & hlsearch !
call assert_equal(1, &hlsearch)
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
set hlsearch &
END
CheckScriptFailure(lines, 'E518:')
set hlsearch
set hlsearch!
assert_equal(false, &hlsearch)
set hlsearch
set hlsearch&
assert_equal(false, &hlsearch)
lines =<< trim END
vim9script
set hlsearch & hlsearch !
set hlsearch &
END
CheckScriptFailure(lines, 'E518:')
CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: &')
lines =<< trim END
set hlsearch !
END
CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: !')
set hlsearch&
enddef
" Keep this last, it messes up highlighting.

View File

@ -1096,7 +1096,10 @@ f_test_garbagecollect_soon(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
void
f_test_ignore_error(typval_T *argvars, typval_T *rettv UNUSED)
{
ignore_error_for_testing(tv_get_string(&argvars[0]));
if (argvars[0].v_type != VAR_STRING)
emsg(_(e_invarg));
else
ignore_error_for_testing(tv_get_string(&argvars[0]));
}
void

View File

@ -605,7 +605,7 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)
{
emsg(_(e_invarg));
emsg(_(e_dictreq));
return;
}
dict = argvars[0].vval.v_dict;

View File

@ -384,6 +384,23 @@ check_for_nonempty_string_arg(typval_T *args, int idx)
return OK;
}
/*
* Give an error and return FAIL unless "tv" is a dict.
*/
int
check_for_dict_arg(typval_T *args, int idx)
{
if (args[idx].v_type != VAR_DICT)
{
if (idx >= 0)
semsg(_(e_dict_required_for_argument_nr), idx + 1);
else
emsg(_(e_dictreq));
return FAIL;
}
return OK;
}
/*
* Get the string value of a variable.
* If it is a Number variable, the number is converted into a string.
@ -456,13 +473,13 @@ tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict)
return buf;
case VAR_FUNC:
case VAR_PARTIAL:
emsg(_("E729: using Funcref as a String"));
emsg(_("E729: Using a Funcref as a String"));
break;
case VAR_LIST:
emsg(_("E730: using List as a String"));
emsg(_("E730: Using a List as a String"));
break;
case VAR_DICT:
emsg(_("E731: using Dictionary as a String"));
emsg(_("E731: Using a Dictionary as a String"));
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
@ -483,7 +500,7 @@ tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict)
STRCPY(buf, get_var_special_name(varp->vval.v_number));
return buf;
case VAR_BLOB:
emsg(_("E976: using Blob as a String"));
emsg(_("E976: Using a Blob as a String"));
break;
case VAR_JOB:
#ifdef FEAT_JOB_CHANNEL

View File

@ -755,6 +755,46 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3137,
/**/
3136,
/**/
3135,
/**/
3134,
/**/
3133,
/**/
3132,
/**/
3131,
/**/
3130,
/**/
3129,
/**/
3128,
/**/
3127,
/**/
3126,
/**/
3125,
/**/
3124,
/**/
3123,
/**/
3122,
/**/
3121,
/**/
3120,
/**/
3119,
/**/
3118,
/**/
3117,
/**/

View File

@ -7932,7 +7932,7 @@ compile_for(char_u *arg_start, cctx_T *cctx)
if (lhs_type == &t_any)
lhs_type = item_type;
else if (item_type != &t_unknown
&& ((var_list && item_type == &t_any)
&& (item_type == &t_any
? need_type(item_type, lhs_type,
-1, 0, cctx, FALSE, FALSE)
: check_type(lhs_type, item_type, TRUE, where))
@ -8563,6 +8563,37 @@ compile_throw(char_u *arg, cctx_T *cctx UNUSED)
return p;
}
static char_u *
compile_eval(char_u *arg, cctx_T *cctx)
{
char_u *p = arg;
int name_only;
char_u *alias;
long lnum = SOURCING_LNUM;
// find_ex_command() will consider a variable name an expression, assuming
// that something follows on the next line. Check that something actually
// follows, otherwise it's probably a misplaced command.
get_name_len(&p, &alias, FALSE, FALSE);
name_only = ends_excmd2(arg, skipwhite(p));
vim_free(alias);
p = arg;
if (compile_expr0(&p, cctx) == FAIL)
return NULL;
if (name_only && lnum == SOURCING_LNUM)
{
semsg(_(e_expression_without_effect_str), arg);
return NULL;
}
// drop the result
generate_instr_drop(cctx, ISN_DROP, 1);
return skipwhite(p);
}
/*
* compile "echo expr"
* compile "echomsg expr"
@ -9630,13 +9661,7 @@ compile_def_function(
break;
case CMD_eval:
if (compile_expr0(&p, &cctx) == FAIL)
goto erret;
// drop the result
generate_instr_drop(&cctx, ISN_DROP, 1);
line = skipwhite(p);
line = compile_eval(p, &cctx);
break;
case CMD_echo:

View File

@ -616,7 +616,7 @@ handle_import(
if (idx < 0 && ufunc == NULL)
goto erret;
// If already imported with the same propertis and the
// If already imported with the same properties and the
// IMP_FLAGS_RELOAD set then we keep that entry. Otherwise create
// a new one (and give an error for an existing import).
imported = find_imported(name, len, cctx);
@ -922,7 +922,7 @@ free_all_script_vars(scriptitem_T *si)
/*
* Find the script-local variable that links to "dest".
* Returns NULL if not found.
* Returns NULL if not found and give an internal error.
*/
svar_T *
find_typval_in_script(typval_T *dest)

View File

@ -1166,7 +1166,7 @@ type_name(type_T *type, char **tofree)
for (i = 0; i < type->tt_argcount; ++i)
{
char *arg_free;
char *arg_free = NULL;
char *arg_type;
int len;