mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Problem: Vim9: runtime and compile time type checks are not the same. Solution: Add more runtime type checks for builtin functions. (Yegappan Lakshmanan, closes #8646)
This commit is contained in:
committed by
Bram Moolenaar
parent
5d7c2df536
commit
4490ec4e83
24
src/time.c
24
src/time.c
@@ -174,6 +174,12 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
if (rettv_list_alloc(rettv) != OK)
|
||||
return;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_opt_list_arg(argvars, 0) == FAIL
|
||||
|| (argvars[0].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_list_arg(argvars, 1) == FAIL)))
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type == VAR_UNKNOWN)
|
||||
{
|
||||
// No arguments: get current time.
|
||||
@@ -228,6 +234,9 @@ f_reltimefloat(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
rettv->v_type = VAR_FLOAT;
|
||||
rettv->vval.v_float = 0;
|
||||
# ifdef FEAT_RELTIME
|
||||
if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
if (list2proftime(&argvars[0], &tm) == OK)
|
||||
rettv->vval.v_float = profile_float(&tm);
|
||||
else if (in_vim9script())
|
||||
@@ -249,6 +258,9 @@ f_reltimestr(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
# ifdef FEAT_RELTIME
|
||||
if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
if (list2proftime(&argvars[0], &tm) == OK)
|
||||
rettv->vval.v_string = vim_strsave((char_u *)profile_msg(&tm));
|
||||
else if (in_vim9script())
|
||||
@@ -342,6 +354,11 @@ f_strptime(typval_T *argvars, typval_T *rettv)
|
||||
vimconv_T conv;
|
||||
char_u *enc;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_string_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
CLEAR_FIELD(tmval);
|
||||
tmval.tm_isdst = -1;
|
||||
fmt = tv_get_string(&argvars[0]);
|
||||
@@ -754,6 +771,10 @@ f_timer_info(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (rettv_list_alloc(rettv) != OK)
|
||||
return;
|
||||
|
||||
if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_UNKNOWN)
|
||||
{
|
||||
if (argvars[0].v_type != VAR_NUMBER)
|
||||
@@ -849,6 +870,9 @@ f_timer_stop(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
timer_T *timer;
|
||||
|
||||
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_NUMBER)
|
||||
{
|
||||
emsg(_(e_number_expected));
|
||||
|
Reference in New Issue
Block a user