Patch 8.2.0564
Problem: Vim9: calling a def function from non-vim9 may fail.
Solution: Convert varargs to a list.
Files: src/testdir/test_vim9_func.vim, src/vim9execute.c
*** ../vim-8.2.0563/src/testdir/test_vim9_func.vim 2020-04-12
21:52:56.875998374 +0200
--- src/testdir/test_vim9_func.vim 2020-04-12 22:06:22.798113797 +0200
***************
*** 576,581 ****
--- 576,588 ----
assert_equal('text777one-two', MultiLine('text', 777, 'one', 'two'))
enddef
+ func Test_multiline_not_vim9()
+ call assert_equal('text1234', MultiLine('text'))
+ call assert_equal('text777', MultiLine('text', 777))
+ call assert_equal('text777one', MultiLine('text', 777, 'one'))
+ call assert_equal('text777one-two', MultiLine('text', 777, 'one', 'two'))
+ endfunc
+
" When using CheckScriptFailure() for the below test, E1010 is generated
instead
" of E1056.
*** ../vim-8.2.0563/src/vim9execute.c 2020-04-12 19:37:13.526297236 +0200
--- src/vim9execute.c 2020-04-12 22:21:03.416634639 +0200
***************
*** 477,487 ****
int
call_def_function(
ufunc_T *ufunc,
! int argc, // nr of arguments
typval_T *argv, // arguments
typval_T *rettv) // return value
{
ectx_T ectx; // execution context
int initial_frame_ptr;
typval_T *tv;
int idx;
--- 477,488 ----
int
call_def_function(
ufunc_T *ufunc,
! int argc_arg, // nr of arguments
typval_T *argv, // arguments
typval_T *rettv) // return value
{
ectx_T ectx; // execution context
+ int argc = argc_arg;
int initial_frame_ptr;
typval_T *tv;
int idx;
***************
*** 512,524 ****
--- 513,546 ----
copy_tv(&argv[idx], STACK_TV_BOT(0));
++ectx.ec_stack.ga_len;
}
+
+ // Turn varargs into a list. Empty list if no args.
+ if (ufunc->uf_va_name != NULL)
+ {
+ int vararg_count = argc - ufunc->uf_args.ga_len;
+
+ if (vararg_count < 0)
+ vararg_count = 0;
+ else
+ argc -= vararg_count;
+ if (exe_newlist(vararg_count, &ectx) == FAIL)
+ goto failed;
+ if (defcount > 0)
+ // Move varargs list to below missing default arguments.
+ *STACK_TV_BOT(defcount- 1) = *STACK_TV_BOT(-1);
+ --ectx.ec_stack.ga_len;
+ }
+
// Make space for omitted arguments, will store default value below.
+ // Any varargs list goes after them.
if (defcount > 0)
for (idx = 0; idx < defcount; ++idx)
{
STACK_TV_BOT(0)->v_type = VAR_UNKNOWN;
++ectx.ec_stack.ga_len;
}
+ if (ufunc->uf_va_name != NULL)
+ ++ectx.ec_stack.ga_len;
// Frame pointer points to just after arguments.
ectx.ec_frame = ectx.ec_stack.ga_len;
*** ../vim-8.2.0563/src/version.c 2020-04-12 21:52:56.875998374 +0200
--- src/version.c 2020-04-12 22:07:19.702067179 +0200
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 564,
/**/
--
It might look like I'm doing nothing, but at the cellular level
I'm really quite busy.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ 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/202004122023.03CKND51008093%40masaka.moolenaar.net.