diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-07-27 22:00:44 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-27 22:00:44 +0200 |
commit | 4490ec4e839e45a2e6923c265c7e9e64c240b805 (patch) | |
tree | 3ef2dc127890ac6a644f38ae7932b7e70071544a /src/time.c | |
parent | 5d7c2df536c17db4a9c61e0760bdcf78d0db7330 (diff) |
patch 8.2.3229: Vim9: runtime and compile time type checks are not the samev8.2.3229
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)
Diffstat (limited to 'src/time.c')
-rw-r--r-- | src/time.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/time.c b/src/time.c index 6557b0e8c0..ecd884f0f6 100644 --- a/src/time.c +++ b/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)); |