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)
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 563e281..f0c5e91 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -321,6 +321,15 @@
lines =<< trim END
vim9script
+ def Func(...l: any)
+ echo l
+ enddef
+ Func(0)
+ END
+ CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
def Func(...l: list<string>)
echo l
enddef
diff --git a/src/version.c b/src/version.c
index c3efafd..be62786 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1695,
+/**/
1694,
/**/
1693,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 075bd12..338fbc6 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1430,8 +1430,8 @@
continue;
expected = ufunc->uf_arg_types[i];
}
- else if (ufunc->uf_va_type == NULL)
- // possibly a lambda
+ else if (ufunc->uf_va_type == NULL || ufunc->uf_va_type == &t_any)
+ // possibly a lambda or "...: any"
expected = &t_any;
else
expected = ufunc->uf_va_type->tt_member;
diff --git a/src/vim9execute.c b/src/vim9execute.c
index ddc20bc..7c8f779 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -829,6 +829,7 @@
// Check the type of the list items.
tv = STACK_TV_BOT(-1);
if (ufunc->uf_va_type != NULL
+ && ufunc->uf_va_type != &t_any
&& ufunc->uf_va_type->tt_member != &t_any
&& tv->vval.v_list != NULL)
{