0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.1695: Vim9: crash when using varargs type "any"

Problem:    Vim9: crash when using varargs type "any".
Solution:   Check if uf_va_type is &t_any. (closes #6957)
This commit is contained in:
Bram Moolenaar 2020-09-16 17:22:59 +02:00
parent 573545a55a
commit 2f8cbc4b22
4 changed files with 14 additions and 2 deletions

View File

@ -319,6 +319,15 @@ def Test_call_def_varargs()
END END
CheckScriptSuccess(lines) CheckScriptSuccess(lines)
lines =<< trim END
vim9script
def Func(...l: any)
echo l
enddef
Func(0)
END
CheckScriptSuccess(lines)
lines =<< trim END lines =<< trim END
vim9script vim9script
def Func(...l: list<string>) def Func(...l: list<string>)

View File

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

View File

@ -1430,8 +1430,8 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
continue; continue;
expected = ufunc->uf_arg_types[i]; expected = ufunc->uf_arg_types[i];
} }
else if (ufunc->uf_va_type == NULL) else if (ufunc->uf_va_type == NULL || ufunc->uf_va_type == &t_any)
// possibly a lambda // possibly a lambda or "...: any"
expected = &t_any; expected = &t_any;
else else
expected = ufunc->uf_va_type->tt_member; expected = ufunc->uf_va_type->tt_member;

View File

@ -829,6 +829,7 @@ call_def_function(
// Check the type of the list items. // Check the type of the list items.
tv = STACK_TV_BOT(-1); tv = STACK_TV_BOT(-1);
if (ufunc->uf_va_type != NULL if (ufunc->uf_va_type != NULL
&& ufunc->uf_va_type != &t_any
&& ufunc->uf_va_type->tt_member != &t_any && ufunc->uf_va_type->tt_member != &t_any
&& tv->vval.v_list != NULL) && tv->vval.v_list != NULL)
{ {