Skip to content

Commit 2f8cbc4

Browse files
committed
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)
1 parent 573545a commit 2f8cbc4

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/testdir/test_vim9_func.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,15 @@ def Test_call_def_varargs()
319319
END
320320
CheckScriptSuccess(lines)
321321

322+
lines =<< trim END
323+
vim9script
324+
def Func(...l: any)
325+
echo l
326+
enddef
327+
Func(0)
328+
END
329+
CheckScriptSuccess(lines)
330+
322331
lines =<< trim END
323332
vim9script
324333
def Func(...l: list<string>)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1695,
753755
/**/
754756
1694,
755757
/**/

src/vim9compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,8 +1430,8 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
14301430
continue;
14311431
expected = ufunc->uf_arg_types[i];
14321432
}
1433-
else if (ufunc->uf_va_type == NULL)
1434-
// possibly a lambda
1433+
else if (ufunc->uf_va_type == NULL || ufunc->uf_va_type == &t_any)
1434+
// possibly a lambda or "...: any"
14351435
expected = &t_any;
14361436
else
14371437
expected = ufunc->uf_va_type->tt_member;

src/vim9execute.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ call_def_function(
829829
// Check the type of the list items.
830830
tv = STACK_TV_BOT(-1);
831831
if (ufunc->uf_va_type != NULL
832+
&& ufunc->uf_va_type != &t_any
832833
&& ufunc->uf_va_type->tt_member != &t_any
833834
&& tv->vval.v_list != NULL)
834835
{

0 commit comments

Comments
 (0)