0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.3308: Vim9: no runtime check for argument type with varargs only

Problem:    Vim9: no runtime check for argument type if a function only has
            varargs.
Solution:   Also check argument types if uf_va_type is set. (closes #8715)
This commit is contained in:
Bram Moolenaar
2021-08-07 15:35:36 +02:00
parent 7de6262373
commit 6ce46b9963
3 changed files with 16 additions and 2 deletions

View File

@@ -1149,6 +1149,18 @@ def Test_call_def_varargs()
enddef
END
CheckScriptFailure(lines, 'E1160:')
lines =<< trim END
vim9script
def DoIt()
g:Later('')
enddef
defcompile
def g:Later(...l: list<number>)
enddef
DoIt()
END
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got string')
enddef
let s:value = ''

View File

@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3308,
/**/
3307,
/**/

View File

@@ -893,7 +893,7 @@ call_by_name(
if (ufunc != NULL)
{
if (ufunc->uf_arg_types != NULL)
if (ufunc->uf_arg_types != NULL || ufunc->uf_va_type != NULL)
{
int i;
typval_T *argv = STACK_TV_BOT(0) - argcount;
@@ -904,7 +904,7 @@ call_by_name(
{
type_T *type = NULL;
if (i < ufunc->uf_args.ga_len)
if (i < ufunc->uf_args.ga_len && ufunc->uf_arg_types != NULL)
type = ufunc->uf_arg_types[i];
else if (ufunc->uf_va_type != NULL)
type = ufunc->uf_va_type->tt_member;