Patch 9.0.0480
Problem: Cannot use a :def varargs function with substitute().
Solution: Use has_varargs(). (closes #11146)
Files: src/regexp.c, src/testdir/test_substitute.vim
*** ../vim-9.0.0479/src/regexp.c 2022-09-16 12:10:00.073526252 +0100
--- src/regexp.c 2022-09-16 16:03:43.462673466 +0100
***************
*** 1824,1830 ****
char_u *s;
typval_T *listarg = argv + argskip;
! if (!fp->uf_varargs && fp->uf_args.ga_len <= argskip)
// called function doesn't take a submatches argument
return argskip;
--- 1824,1830 ----
char_u *s;
typval_T *listarg = argv + argskip;
! if (!has_varargs(fp) && fp->uf_args.ga_len <= argskip)
// called function doesn't take a submatches argument
return argskip;
*** ../vim-9.0.0479/src/testdir/test_substitute.vim 2022-09-16
12:10:00.073526252 +0100
--- src/testdir/test_substitute.vim 2022-09-16 16:03:43.462673466 +0100
***************
*** 442,447 ****
--- 442,450 ----
func SubReplacerVar(text, ...)
return a:text .. a:1[0] .. a:text
endfunc
+ def SubReplacerVar9(text: string, ...args: list<list<string>>): string
+ return text .. args[0][0] .. text
+ enddef
func SubReplacer20(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13,
t14, t15, t16, t17, t18, t19, submatches)
return a:t3 .. a:submatches[0] .. a:t11
endfunc
***************
*** 449,454 ****
--- 452,458 ----
func Test_substitute_partial()
call assert_equal('1foo2foo3', substitute('123', '2',
function('SubReplacer', ['foo']), 'g'))
call assert_equal('1foo2foo3', substitute('123', '2',
function('SubReplacerVar', ['foo']), 'g'))
+ call assert_equal('1foo2foo3', substitute('123', '2',
function('SubReplacerVar9', ['foo']), 'g'))
" 19 arguments plus one is just OK
let Replacer = function('SubReplacer20', repeat(['foo'], 19))
*** ../vim-9.0.0479/src/version.c 2022-09-16 15:46:57.392979652 +0100
--- src/version.c 2022-09-16 16:04:58.978485646 +0100
***************
*** 705,706 ****
--- 705,708 ----
{ /* Add new patch number below this line */
+ /**/
+ 480,
/**/
--
Where do you want to crash today?
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220916150707.3B58B1C0846%40moolenaar.net.