changeset 30043:fd855ad74887 v9.0.0359

patch 9.0.0359: error message for wrong argument type is not specific Commit: https://github.com/vim/vim/commit/8deb2b30c77035bb682ccf80b781455ac1d6038b Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Fri Sep 2 15:15:27 2022 +0100 patch 9.0.0359: error message for wrong argument type is not specific Problem: Error message for wrong argument type is not specific. Solution: Include more information in the error. (Yegappan Lakshmanan, closes #11037)
author Bram Moolenaar <Bram@vim.org>
date Fri, 02 Sep 2022 16:30:07 +0200
parents 24d37e312b7b
children 065ac3ad11fb
files src/blob.c src/cmdexpand.c src/evalfunc.c src/popupwin.c src/sign.c src/strings.c src/testdir/test_assert.vim src/testdir/test_cmdline.vim src/testdir/test_functions.vim src/testdir/test_listdict.vim src/testdir/test_signs.vim src/testdir/test_tagjump.vim src/testdir/test_timers.vim src/testdir/test_vim9_builtin.vim src/testing.c src/time.c src/version.c
diffstat 17 files changed, 118 insertions(+), 196 deletions(-) [+]
line wrap: on
line diff
--- a/src/blob.c
+++ b/src/blob.c
@@ -667,11 +667,8 @@ blob_reduce(
 	initial.vval.v_number = blob_get(b, 0);
 	i = 1;
     }
-    else if (argvars[2].v_type != VAR_NUMBER)
-    {
-	emsg(_(e_number_expected));
+    else if (check_for_number_arg(argvars, 2) == FAIL)
 	return;
-    }
     else
     {
 	initial = argvars[2];
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -3679,11 +3679,8 @@ f_getcompletion(typval_T *argvars, typva
 	return;
 
     pat = tv_get_string(&argvars[0]);
-    if (argvars[1].v_type != VAR_STRING)
-    {
-	semsg(_(e_invalid_argument_str), "type must be a string");
+    if (check_for_string_arg(argvars, 1) == FAIL)
 	return;
-    }
     type = tv_get_string(&argvars[1]);
 
     if (argvars[2].v_type != VAR_UNKNOWN)
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3607,17 +3607,13 @@ f_deepcopy(typval_T *argvars, typval_T *
 {
     varnumber_T	noref = 0;
 
-    if (in_vim9script()
-	    && (check_for_opt_bool_arg(argvars, 1) == FAIL))
+    if (check_for_opt_bool_arg(argvars, 1) == FAIL)
 	return;
 
     if (argvars[1].v_type != VAR_UNKNOWN)
 	noref = tv_get_bool_chk(&argvars[1], NULL);
-    if (noref < 0 || noref > 1)
-	semsg(_(e_using_number_as_bool_nr), noref);
-    else
-	item_copy(&argvars[0], rettv, TRUE, TRUE,
-						noref == 0 ? get_copyID() : 0);
+
+    item_copy(&argvars[0], rettv, TRUE, TRUE, noref == 0 ? get_copyID() : 0);
 }
 
 /*
@@ -5257,21 +5253,11 @@ f_gettagstack(typval_T *argvars, typval_
     static void
 f_gettext(typval_T *argvars, typval_T *rettv)
 {
-    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
-	return;
-
-    if (argvars[0].v_type != VAR_STRING
-	    || argvars[0].vval.v_string == NULL
-	    || *argvars[0].vval.v_string == NUL)
-    {
-	semsg(_(e_invalid_argument_str), tv_get_string(&argvars[0]));
-    }
-    else
-    {
-	rettv->v_type = VAR_STRING;
-	rettv->vval.v_string = vim_strsave(
-					(char_u *)_(argvars[0].vval.v_string));
-    }
+    if (check_for_nonempty_string_arg(argvars, 0) == FAIL)
+	return;
+
+    rettv->v_type = VAR_STRING;
+    rettv->vval.v_string = vim_strsave((char_u *)_(argvars[0].vval.v_string));
 }
 
 // for VIM_VERSION_ defines
@@ -9641,7 +9627,9 @@ f_settagstack(typval_T *argvars, typval_
     // default is to replace the stack.
     if (argvars[2].v_type == VAR_UNKNOWN)
 	action = 'r';
-    else if (argvars[2].v_type == VAR_STRING)
+    else if (check_for_string_arg(argvars, 2) == FAIL)
+	return;
+    else
     {
 	char_u	*actstr;
 	actstr = tv_get_string_chk(&argvars[2]);
@@ -9656,11 +9644,6 @@ f_settagstack(typval_T *argvars, typval_
 	    return;
 	}
     }
-    else
-    {
-	emsg(_(e_string_required));
-	return;
-    }
 
     if (set_tagstack(wp, d, action) == OK)
 	rettv->vval.v_number = 0;
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2769,9 +2769,7 @@ f_popup_settext(typval_T *argvars, typva
     wp = find_popup_win(id);
     if (wp != NULL)
     {
-	if (argvars[1].v_type != VAR_STRING && argvars[1].v_type != VAR_LIST)
-	    semsg(_(e_invalid_argument_str), tv_get_string(&argvars[1]));
-	else
+	if (check_for_string_or_list_arg(argvars, 1) != FAIL)
 	{
 	    popup_set_buffer_text(wp->w_buffer, argvars[1]);
 	    redraw_win_later(wp, UPD_NOT_VALID);
--- a/src/sign.c
+++ b/src/sign.c
@@ -2849,23 +2849,12 @@ f_sign_unplace(typval_T *argvars, typval
 
     rettv->vval.v_number = -1;
 
-    if (in_vim9script()
-	    && (check_for_string_arg(argvars, 0) == FAIL
+    if ((check_for_string_arg(argvars, 0) == FAIL
 		|| check_for_opt_dict_arg(argvars, 1) == FAIL))
 	return;
 
-    if (argvars[0].v_type != VAR_STRING)
-    {
-	emsg(_(e_invalid_argument));
-	return;
-    }
-
     if (argvars[1].v_type != VAR_UNKNOWN)
-    {
-	if (check_for_dict_arg(argvars, 1) == FAIL)
-	    return;
 	dict = argvars[1].vval.v_dict;
-    }
 
     rettv->vval.v_number = sign_unplace_from_dict(&argvars[0], dict);
 }
--- a/src/strings.c
+++ b/src/strings.c
@@ -960,11 +960,8 @@ string_reduce(
 	    return;
 	p += STRLEN(rettv->vval.v_string);
     }
-    else if (argvars[2].v_type != VAR_STRING)
-    {
-	semsg(_(e_string_expected_for_argument_nr), 3);
+    else if (check_for_string_arg(argvars, 2) == FAIL)
 	return;
-    }
     else
 	copy_tv(&argvars[2], rettv);
 
@@ -1047,21 +1044,11 @@ f_charidx(typval_T *argvars, typval_T *r
 
     rettv->vval.v_number = -1;
 
-    if (in_vim9script()
-	    && (check_for_string_arg(argvars, 0) == FAIL
+    if ((check_for_string_arg(argvars, 0) == FAIL
 		|| check_for_number_arg(argvars, 1) == FAIL
 		|| check_for_opt_bool_arg(argvars, 2) == FAIL))
 	return;
 
-    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_BOOL))
-    {
-	emsg(_(e_invalid_argument));
-	return;
-    }
-
     str = tv_get_string_chk(&argvars[0]);
     idx = tv_get_number_chk(&argvars[1], NULL);
     if (str == NULL || idx < 0)
@@ -1783,11 +1770,8 @@ f_trim(typval_T *argvars, typval_T *rett
     if (head == NULL)
 	return;
 
-    if (argvars[1].v_type != VAR_UNKNOWN && argvars[1].v_type != VAR_STRING)
-    {
-	semsg(_(e_invalid_argument_str), tv_get_string(&argvars[1]));
+    if (check_for_opt_string_arg(argvars, 1) == FAIL)
 	return;
-    }
 
     if (argvars[1].v_type == VAR_STRING)
     {
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -368,7 +368,7 @@ func Test_override()
   eval 1->test_override('redraw')
   call test_override('ALL', 0)
   call assert_fails("call test_override('xxx', 1)", 'E475:')
-  call assert_fails("call test_override('redraw', 'yes')", 'E474:')
+  call assert_fails("call test_override('redraw', 'yes')", 'E1210:')
 endfunc
 
 func Test_mouse_position()
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -605,7 +605,7 @@ func Test_getcompletion()
 
   call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E871:')
   call assert_fails('call getcompletion("", "burp")', 'E475:')
-  call assert_fails('call getcompletion("abc", [])', 'E475:')
+  call assert_fails('call getcompletion("abc", [])', 'E1174:')
 endfunc
 
 " Test for getcompletion() with "fuzzy" in 'wildoptions'
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1247,11 +1247,11 @@ func Test_charidx()
   call assert_equal(-1, charidx(a, 8, 1))
   call assert_equal(-1, charidx('', 0, 1))
 
-  call assert_fails('let x = charidx([], 1)', 'E474:')
-  call assert_fails('let x = charidx("abc", [])', 'E474:')
-  call assert_fails('let x = charidx("abc", 1, [])', 'E474:')
-  call assert_fails('let x = charidx("abc", 1, -1)', 'E1023:')
-  call assert_fails('let x = charidx("abc", 1, 2)', 'E1023:')
+  call assert_fails('let x = charidx([], 1)', 'E1174:')
+  call assert_fails('let x = charidx("abc", [])', 'E1210:')
+  call assert_fails('let x = charidx("abc", 1, [])', 'E1212:')
+  call assert_fails('let x = charidx("abc", 1, -1)', 'E1212:')
+  call assert_fails('let x = charidx("abc", 1, 2)', 'E1212:')
 endfunc
 
 func Test_count()
@@ -1738,7 +1738,7 @@ func Test_trim()
   call assert_fails('eval trim("  vim  ", " ", [])', 'E745:')
   call assert_fails('eval trim("  vim  ", " ", -1)', 'E475:')
   call assert_fails('eval trim("  vim  ", " ", 3)', 'E475:')
-  call assert_fails('eval trim("  vim  ", 0)', 'E475:')
+  call assert_fails('eval trim("  vim  ", 0)', 'E1174:')
 
   let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '')
   call assert_equal("x", trim(chars . "x" . chars))
@@ -2913,7 +2913,7 @@ endfunc
 
 " Test for gettext()
 func Test_gettext()
-  call assert_fails('call gettext(1)', 'E475:')
+  call assert_fails('call gettext(1)', 'E1174:')
 endfunc
 
 func Test_builtin_check()
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -568,7 +568,7 @@ func Test_dict_deepcopy()
   END
   call v9.CheckLegacyAndVim9Success(lines)
 
-  call assert_fails("call deepcopy([1, 2], 2)", 'E1023:')
+  call assert_fails("call deepcopy([1, 2], 2)", 'E1212:')
 endfunc
 
 " Locked variables
@@ -1044,16 +1044,16 @@ func Test_reduce()
   call assert_fails("call reduce({}, { acc, val -> acc + val }, 1)", 'E1098:')
   call assert_fails("call reduce(0, { acc, val -> acc + val }, 1)", 'E1098:')
   call assert_fails("call reduce([1, 2], 'Xdoes_not_exist')", 'E117:')
-  call assert_fails("echo reduce(0z01, { acc, val -> 2 * acc + val }, '')", 'E39:')
+  call assert_fails("echo reduce(0z01, { acc, val -> 2 * acc + val }, '')", 'E1210:')
 
   call assert_fails("vim9 reduce(0, (acc, val) => (acc .. val), '')", 'E1252:')
   call assert_fails("vim9 reduce({}, (acc, val) => (acc .. val), '')", 'E1252:')
   call assert_fails("vim9 reduce(0.1, (acc, val) => (acc .. val), '')", 'E1252:')
   call assert_fails("vim9 reduce(function('tr'), (acc, val) => (acc .. val), '')", 'E1252:')
-  call assert_fails("call reduce('', { acc, val -> acc + val }, 1)", 'E1253:')
-  call assert_fails("call reduce('', { acc, val -> acc + val }, {})", 'E1253:')
-  call assert_fails("call reduce('', { acc, val -> acc + val }, 0.1)", 'E1253:')
-  call assert_fails("call reduce('', { acc, val -> acc + val }, function('tr'))", 'E1253:')
+  call assert_fails("call reduce('', { acc, val -> acc + val }, 1)", 'E1174:')
+  call assert_fails("call reduce('', { acc, val -> acc + val }, {})", 'E1174:')
+  call assert_fails("call reduce('', { acc, val -> acc + val }, 0.1)", 'E1174:')
+  call assert_fails("call reduce('', { acc, val -> acc + val }, function('tr'))", 'E1174:')
   call assert_fails("call reduce('abc', { a, v -> a10}, '')", 'E121:')
   call assert_fails("call reduce(0z0102, { a, v -> a10}, 1)", 'E121:')
   call assert_fails("call reduce([1, 2], { a, v -> a10}, '')", 'E121:')
--- a/src/testdir/test_signs.vim
+++ b/src/testdir/test_signs.vim
@@ -686,7 +686,7 @@ func Test_sign_group()
   call assert_equal([], sign_getplaced(bnum, {'group' : '*'})[0].signs)
 
   " Error case
-  call assert_fails("call sign_unplace({})", 'E474:')
+  call assert_fails("call sign_unplace({})", 'E1174:')
 
   " Place a sign in the global group and try to delete it using a group
   call assert_equal(5, sign_place(5, '', 'sign1', bnum, {'lnum' : 10}))
--- a/src/testdir/test_tagjump.vim
+++ b/src/testdir/test_tagjump.vim
@@ -405,7 +405,7 @@ func Test_getsettagstack()
   call assert_equal(-1, settagstack(100, {'items' : []}))
   call assert_fails('call settagstack(1, [1, 10])', 'E1206:')
   call assert_fails("call settagstack(1, {'items' : 10})", 'E714:')
-  call assert_fails("call settagstack(1, {'items' : []}, 10)", 'E928:')
+  call assert_fails("call settagstack(1, {'items' : []}, 10)", 'E1174:')
   call assert_fails("call settagstack(1, {'items' : []}, 'b')", 'E962:')
   call assert_equal(-1, settagstack(0, test_null_dict()))
 
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -116,7 +116,7 @@ func Test_timer_info()
   call timer_stop(id)
   call assert_equal([], timer_info(id))
 
-  call assert_fails('call timer_info("abc")', 'E39:')
+  call assert_fails('call timer_info("abc")', 'E1210:')
 
   " check repeat count inside the callback
   let g:timer_repeat = []
@@ -267,7 +267,7 @@ func Test_timer_errors()
 
   call assert_fails('call timer_start(100, "MyHandler", "abc")', 'E1206:')
   call assert_fails('call timer_start(100, [])', 'E921:')
-  call assert_fails('call timer_stop("abc")', 'E39:')
+  call assert_fails('call timer_stop("abc")', 'E1210:')
 endfunc
 
 func FuncWithCaughtError(timer)
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1961,9 +1961,9 @@ enddef
 
 def Test_gettext()
   v9.CheckDefAndScriptFailure(['gettext(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
-  v9.CheckDefExecAndScriptFailure(['gettext("")'], 'E475: Invalid argument')
+  v9.CheckDefExecAndScriptFailure(['gettext("")'], 'E1175: Non-empty string required for argument 1')
   assert_equal('abc', gettext("abc"))
-  assert_fails('gettext("")', 'E475:')
+  assert_fails('gettext("")', 'E1175:')
 enddef
 
 def Test_getwininfo()
--- a/src/testing.c
+++ b/src/testing.c
@@ -970,20 +970,17 @@ f_test_feedinput(typval_T *argvars, typv
     void
 f_test_getvalue(typval_T *argvars, typval_T *rettv)
 {
-    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+    char_u *name;
+
+    if (check_for_string_arg(argvars, 0) == FAIL)
 	return;
 
-    if (argvars[0].v_type != VAR_STRING)
-	emsg(_(e_invalid_argument));
-    else
-    {
-	char_u *name = tv_get_string(&argvars[0]);
+    name = tv_get_string(&argvars[0]);
 
-	if (STRCMP(name, (char_u *)"need_fileinfo") == 0)
-	    rettv->vval.v_number = need_fileinfo;
-	else
-	    semsg(_(e_invalid_argument_str), name);
-    }
+    if (STRCMP(name, (char_u *)"need_fileinfo") == 0)
+	rettv->vval.v_number = need_fileinfo;
+    else
+	semsg(_(e_invalid_argument_str), name);
 }
 
 /*
@@ -994,17 +991,12 @@ f_test_option_not_set(typval_T *argvars,
 {
     char_u *name = (char_u *)"";
 
-    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+    if (check_for_string_arg(argvars, 0) == FAIL)
 	return;
 
-    if (argvars[0].v_type != VAR_STRING)
-	emsg(_(e_invalid_argument));
-    else
-    {
-	name = tv_get_string(&argvars[0]);
-	if (reset_option_was_set(name) == FAIL)
-	    semsg(_(e_invalid_argument_str), name);
-    }
+    name = tv_get_string(&argvars[0]);
+    if (reset_option_was_set(name) == FAIL)
+	semsg(_(e_invalid_argument_str), name);
 }
 
 /*
@@ -1017,77 +1009,70 @@ f_test_override(typval_T *argvars, typva
     int     val;
     static int save_starting = -1;
 
-    if (in_vim9script()
-	    && (check_for_string_arg(argvars, 0) == FAIL
-		|| check_for_number_arg(argvars, 1) == FAIL))
+    if (check_for_string_arg(argvars, 0) == FAIL
+		|| check_for_number_arg(argvars, 1) == FAIL)
 	return;
 
-    if (argvars[0].v_type != VAR_STRING
-	    || (argvars[1].v_type) != VAR_NUMBER)
-	emsg(_(e_invalid_argument));
-    else
-    {
-	name = tv_get_string(&argvars[0]);
-	val = (int)tv_get_number(&argvars[1]);
+    name = tv_get_string(&argvars[0]);
+    val = (int)tv_get_number(&argvars[1]);
 
-	if (STRCMP(name, (char_u *)"redraw") == 0)
-	    disable_redraw_for_testing = val;
-	else if (STRCMP(name, (char_u *)"redraw_flag") == 0)
-	    ignore_redraw_flag_for_testing = val;
-	else if (STRCMP(name, (char_u *)"char_avail") == 0)
-	    disable_char_avail_for_testing = val;
-	else if (STRCMP(name, (char_u *)"starting") == 0)
+    if (STRCMP(name, (char_u *)"redraw") == 0)
+	disable_redraw_for_testing = val;
+    else if (STRCMP(name, (char_u *)"redraw_flag") == 0)
+	ignore_redraw_flag_for_testing = val;
+    else if (STRCMP(name, (char_u *)"char_avail") == 0)
+	disable_char_avail_for_testing = val;
+    else if (STRCMP(name, (char_u *)"starting") == 0)
+    {
+	if (val)
 	{
-	    if (val)
-	    {
-		if (save_starting < 0)
-		    save_starting = starting;
-		starting = 0;
-	    }
-	    else
-	    {
-		starting = save_starting;
-		save_starting = -1;
-	    }
-	}
-	else if (STRCMP(name, (char_u *)"nfa_fail") == 0)
-	    nfa_fail_for_testing = val;
-	else if (STRCMP(name, (char_u *)"no_query_mouse") == 0)
-	    no_query_mouse_for_testing = val;
-	else if (STRCMP(name, (char_u *)"no_wait_return") == 0)
-	    no_wait_return = val;
-	else if (STRCMP(name, (char_u *)"ui_delay") == 0)
-	    ui_delay_for_testing = val;
-	else if (STRCMP(name, (char_u *)"term_props") == 0)
-	    reset_term_props_on_termresponse = val;
-	else if (STRCMP(name, (char_u *)"vterm_title") == 0)
-	    disable_vterm_title_for_testing = val;
-	else if (STRCMP(name, (char_u *)"uptime") == 0)
-	    override_sysinfo_uptime = val;
-	else if (STRCMP(name, (char_u *)"alloc_lines") == 0)
-	    ml_get_alloc_lines = val;
-	else if (STRCMP(name, (char_u *)"autoload") == 0)
-	    override_autoload = val;
-	else if (STRCMP(name, (char_u *)"ALL") == 0)
-	{
-	    disable_char_avail_for_testing = FALSE;
-	    disable_redraw_for_testing = FALSE;
-	    ignore_redraw_flag_for_testing = FALSE;
-	    nfa_fail_for_testing = FALSE;
-	    no_query_mouse_for_testing = FALSE;
-	    ui_delay_for_testing = 0;
-	    reset_term_props_on_termresponse = FALSE;
-	    override_sysinfo_uptime = -1;
-	    // ml_get_alloc_lines is not reset by "ALL"
-	    if (save_starting >= 0)
-	    {
-		starting = save_starting;
-		save_starting = -1;
-	    }
+	    if (save_starting < 0)
+		save_starting = starting;
+	    starting = 0;
 	}
 	else
-	    semsg(_(e_invalid_argument_str), name);
+	{
+	    starting = save_starting;
+	    save_starting = -1;
+	}
     }
+    else if (STRCMP(name, (char_u *)"nfa_fail") == 0)
+	nfa_fail_for_testing = val;
+    else if (STRCMP(name, (char_u *)"no_query_mouse") == 0)
+	no_query_mouse_for_testing = val;
+    else if (STRCMP(name, (char_u *)"no_wait_return") == 0)
+	no_wait_return = val;
+    else if (STRCMP(name, (char_u *)"ui_delay") == 0)
+	ui_delay_for_testing = val;
+    else if (STRCMP(name, (char_u *)"term_props") == 0)
+	reset_term_props_on_termresponse = val;
+    else if (STRCMP(name, (char_u *)"vterm_title") == 0)
+	disable_vterm_title_for_testing = val;
+    else if (STRCMP(name, (char_u *)"uptime") == 0)
+	override_sysinfo_uptime = val;
+    else if (STRCMP(name, (char_u *)"alloc_lines") == 0)
+	ml_get_alloc_lines = val;
+    else if (STRCMP(name, (char_u *)"autoload") == 0)
+	override_autoload = val;
+    else if (STRCMP(name, (char_u *)"ALL") == 0)
+    {
+	disable_char_avail_for_testing = FALSE;
+	disable_redraw_for_testing = FALSE;
+	ignore_redraw_flag_for_testing = FALSE;
+	nfa_fail_for_testing = FALSE;
+	no_query_mouse_for_testing = FALSE;
+	ui_delay_for_testing = 0;
+	reset_term_props_on_termresponse = FALSE;
+	override_sysinfo_uptime = -1;
+	// ml_get_alloc_lines is not reset by "ALL"
+	if (save_starting >= 0)
+	{
+	    starting = save_starting;
+	    save_starting = -1;
+	}
+    }
+    else
+	semsg(_(e_invalid_argument_str), name);
 }
 
 /*
@@ -1184,13 +1169,10 @@ f_test_garbagecollect_soon(typval_T *arg
     void
 f_test_ignore_error(typval_T *argvars, typval_T *rettv UNUSED)
 {
-    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+    if (check_for_string_arg(argvars, 0) == FAIL)
 	return;
 
-    if (argvars[0].v_type != VAR_STRING)
-	emsg(_(e_invalid_argument));
-    else
-	ignore_error_for_testing(tv_get_string(&argvars[0]));
+    ignore_error_for_testing(tv_get_string(&argvars[0]));
 }
 
     void
@@ -1271,7 +1253,7 @@ f_test_setmouse(typval_T *argvars, typva
 		|| check_for_number_arg(argvars, 1) == FAIL))
 	return;
 
-    if (argvars[0].v_type != VAR_NUMBER || (argvars[1].v_type) != VAR_NUMBER)
+    if (argvars[0].v_type != VAR_NUMBER || argvars[1].v_type != VAR_NUMBER)
     {
 	emsg(_(e_invalid_argument));
 	return;
--- a/src/time.c
+++ b/src/time.c
@@ -805,19 +805,14 @@ f_timer_info(typval_T *argvars, typval_T
     if (rettv_list_alloc(rettv) == FAIL)
 	return;
 
-    if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
+    if (check_for_opt_number_arg(argvars, 0) == FAIL)
 	return;
 
     if (argvars[0].v_type != VAR_UNKNOWN)
     {
-	if (argvars[0].v_type != VAR_NUMBER)
-	    emsg(_(e_number_expected));
-	else
-	{
-	    timer = find_timer((int)tv_get_number(&argvars[0]));
-	    if (timer != NULL)
-		add_timer_info(rettv, timer);
-	}
+	timer = find_timer((int)tv_get_number(&argvars[0]));
+	if (timer != NULL)
+	    add_timer_info(rettv, timer);
     }
     else
 	add_timer_info_all(rettv);
@@ -909,14 +904,9 @@ f_timer_stop(typval_T *argvars, typval_T
 {
     timer_T *timer;
 
-    if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
+    if (check_for_number_arg(argvars, 0) == FAIL)
 	return;
 
-    if (argvars[0].v_type != VAR_NUMBER)
-    {
-	emsg(_(e_number_expected));
-	return;
-    }
     timer = find_timer((int)tv_get_number(&argvars[0]));
     if (timer != NULL)
 	stop_timer(timer);
--- a/src/version.c
+++ b/src/version.c
@@ -708,6 +708,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    359,
+/**/
     358,
 /**/
     357,