Patch 8.2.4998
Problem: Vim9: crash when using multiple funcref().
Solution: Check if varargs type is NULL. (closes #10467)
Files: src/vim9type.c, src/testdir/test_vim9_func.vim
*** ../vim-8.2.4997/src/vim9type.c 2022-03-31 20:02:52.422045605 +0100
--- src/vim9type.c 2022-05-22 13:32:56.083620515 +0100
***************
*** 807,813 ****
else
tv = &argvars[i];
if (varargs && i >= type->tt_argcount - 1)
! expected = type->tt_args[type->tt_argcount - 1]->tt_member;
else
expected = type->tt_args[i];
if (check_typval_arg_type(expected, tv, NULL, i + 1) == FAIL)
--- 807,817 ----
else
tv = &argvars[i];
if (varargs && i >= type->tt_argcount - 1)
! {
! expected = type->tt_args[type->tt_argcount - 1];
! if (expected != NULL)
! expected = expected->tt_member;
! }
else
expected = type->tt_args[i];
if (check_typval_arg_type(expected, tv, NULL, i + 1) == FAIL)
*** ../vim-8.2.4997/src/testdir/test_vim9_func.vim 2022-05-13 13:50:32.815012765 +0100
--- src/testdir/test_vim9_func.vim 2022-05-22 13:32:39.655688312 +0100
***************
*** 4107,4112 ****
--- 4107,4153 ----
bw!
endfunc
+ def Test_multiple_funcref()
+ # This was using a NULL pointer
+ var lines =<< trim END
+ vim9script
+ def A(F: func, ...args: list<any>): func
+ return funcref(F, args)
+ enddef
+
+ def B(F: func): func
+ return funcref(A, [F])
+ enddef
+
+ def Test(n: number)
+ enddef
+
+ const X = B(Test)
+ X(1)
+ END
+ v9.CheckScriptSuccess(lines)
+
+ # slightly different case
+ lines =<< trim END
+ vim9script
+
+ def A(F: func, ...args: list<any>): any
+ return call(F, args)
+ enddef
+
+ def B(F: func): func
+ return funcref(A, [F])
+ enddef
+
+ def Test(n: number)
+ enddef
+
+ const X = B(Test)
+ X(1)
+ END
+ v9.CheckScriptSuccess(lines)
+ enddef
+
" The following messes up syntax highlight, keep near the end.
if has('python3')
def Test_python3_command()
*** ../vim-8.2.4997/src/version.c 2022-05-22 12:23:43.271595457 +0100
--- src/version.c 2022-05-22 13:45:32.033800612 +0100
***************
*** 736,737 ****
--- 736,739 ----
{ /* Add new patch number below this line */
+ /**/
+ 4998,
/**/
--
Place mark here ->[ ]<- if you want a dirty monitor.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///