Patch 8.2.3308

6 views
Skip to first unread message

Bram Moolenaar

unread,
Aug 7, 2021, 9:36:23 AM8/7/21
to vim...@googlegroups.com

Patch 8.2.3308
Problem: Vim9: no runtime check for argument type if a function only has
varargs.
Solution: Also check argument types if uf_va_type is set. (closes #8715)
Files: src/vim9execute.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.3307/src/vim9execute.c 2021-08-07 15:05:44.707105779 +0200
--- src/vim9execute.c 2021-08-07 15:32:16.154608967 +0200
***************
*** 893,899 ****

if (ufunc != NULL)
{
! if (ufunc->uf_arg_types != NULL)
{
int i;
typval_T *argv = STACK_TV_BOT(0) - argcount;
--- 893,899 ----

if (ufunc != NULL)
{
! if (ufunc->uf_arg_types != NULL || ufunc->uf_va_type != NULL)
{
int i;
typval_T *argv = STACK_TV_BOT(0) - argcount;
***************
*** 904,910 ****
{
type_T *type = NULL;

! if (i < ufunc->uf_args.ga_len)
type = ufunc->uf_arg_types[i];
else if (ufunc->uf_va_type != NULL)
type = ufunc->uf_va_type->tt_member;
--- 904,910 ----
{
type_T *type = NULL;

! if (i < ufunc->uf_args.ga_len && ufunc->uf_arg_types != NULL)
type = ufunc->uf_arg_types[i];
else if (ufunc->uf_va_type != NULL)
type = ufunc->uf_va_type->tt_member;
*** ../vim-8.2.3307/src/testdir/test_vim9_func.vim 2021-08-03 21:16:14.513239986 +0200
--- src/testdir/test_vim9_func.vim 2021-08-07 15:31:38.046713928 +0200
***************
*** 1149,1154 ****
--- 1149,1166 ----
enddef
END
CheckScriptFailure(lines, 'E1160:')
+
+ lines =<< trim END
+ vim9script
+ def DoIt()
+ g:Later('')
+ enddef
+ defcompile
+ def g:Later(...l: list<number>)
+ enddef
+ DoIt()
+ END
+ CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got string')
enddef

let s:value = ''
*** ../vim-8.2.3307/src/version.c 2021-08-07 15:05:44.711105767 +0200
--- src/version.c 2021-08-07 15:34:08.218299196 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3308,
/**/

--
There are 2 kinds of people in my world: those who know Unix, Perl, Vim, GNU,
Linux, etc, and those who know COBOL. It gets very difficult for me at
parties, not knowing which group to socialise with :-)
Sitaram Chamarty

/// 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 ///
Reply all
Reply to author
Forward
0 new messages