mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.2.3162: Vim9: argument types are not checked at compile time
Problem: Vim9: argument types are not checked at compile time. Solution: Add more type checks. (Yegappan Lakshmanan, closes #8560)
This commit is contained in:
committed by
Bram Moolenaar
parent
c816a2c226
commit
1a71d31bf3
27
src/time.c
27
src/time.c
@@ -169,6 +169,10 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
# ifdef FEAT_RELTIME
|
||||
proftime_T res;
|
||||
proftime_T start;
|
||||
long n1, n2;
|
||||
|
||||
if (rettv_list_alloc(rettv) != OK)
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type == VAR_UNKNOWN)
|
||||
{
|
||||
@@ -198,20 +202,15 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
profile_sub(&res, &start);
|
||||
}
|
||||
|
||||
if (rettv_list_alloc(rettv) == OK)
|
||||
{
|
||||
long n1, n2;
|
||||
|
||||
# ifdef MSWIN
|
||||
n1 = res.HighPart;
|
||||
n2 = res.LowPart;
|
||||
n1 = res.HighPart;
|
||||
n2 = res.LowPart;
|
||||
# else
|
||||
n1 = res.tv_sec;
|
||||
n2 = res.tv_usec;
|
||||
n1 = res.tv_sec;
|
||||
n2 = res.tv_usec;
|
||||
# endif
|
||||
list_append_number(rettv->vval.v_list, (varnumber_T)n1);
|
||||
list_append_number(rettv->vval.v_list, (varnumber_T)n2);
|
||||
}
|
||||
list_append_number(rettv->vval.v_list, (varnumber_T)n1);
|
||||
list_append_number(rettv->vval.v_list, (varnumber_T)n2);
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -269,6 +268,12 @@ f_strftime(typval_T *argvars, typval_T *rettv)
|
||||
time_t seconds;
|
||||
char_u *p;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& check_for_number_arg(argvars, 1) == FAIL)))
|
||||
return;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
|
||||
p = tv_get_string(&argvars[0]);
|
||||
|
Reference in New Issue
Block a user