summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-16 17:22:59 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-16 17:22:59 +0200
commit2f8cbc4b225ba707c3926070a3f133eb0473aed2 (patch)
treefc33529dde4d4cb319c3ad93a2a2150a908f9a89
parent573545a55afb5d42614cdb69f356abb32409270b (diff)
downloadvim-git-2f8cbc4b225ba707c3926070a3f133eb0473aed2.tar.gz
patch 8.2.1695: Vim9: crash when using varargs type "any"v8.2.1695
Problem: Vim9: crash when using varargs type "any". Solution: Check if uf_va_type is &t_any. (closes #6957)
-rw-r--r--src/testdir/test_vim9_func.vim9
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c4
-rw-r--r--src/vim9execute.c1
4 files changed, 14 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 563e281a0..f0c5e9139 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -321,6 +321,15 @@ def Test_call_def_varargs()
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 c3efafd0b..be6278605 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
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 075bd12c4..338fbc639 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1430,8 +1430,8 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
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 ddc20bce8..7c8f77977 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -829,6 +829,7 @@ call_def_function(
// 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)
{