Patch 8.2.1136
Problem: Vim9: return type of argv() is always any.
Solution: Use list<string> if there is no argument.
Files: src/evalfunc.c, src/testdir/test_vim9_func.vim
*** ../vim-8.2.1135/src/evalfunc.c 2020-07-05 16:07:18.605112076 +0200
--- src/evalfunc.c 2020-07-05 17:02:46.712031347 +0200
***************
*** 371,376 ****
--- 371,387 ----
return &t_list_dict_any;
}
+ static type_T *
+ ret_argv(int argcount, type_T **argtypes UNUSED)
+ {
+ // argv() returns list of strings
+ if (argcount == 0)
+ return &t_list_string;
+
+ // argv(0) returns a string, but argv(-1] returns a list
+ return &t_any;
+ }
+
static type_T *ret_f_function(int argcount, type_T **argtypes);
/*
***************
*** 448,454 ****
{"argc", 0, 1, 0, ret_number, f_argc},
{"argidx", 0, 0, 0, ret_number, f_argidx},
{"arglistid", 0, 2, 0, ret_number, f_arglistid},
! {"argv", 0, 2, 0, ret_any, f_argv},
{"asin", 1, 1, FEARG_1, ret_float, FLOAT_FUNC(f_asin)},
{"assert_beeps", 1, 2, FEARG_1, ret_number, f_assert_beeps},
{"assert_equal", 2, 3, FEARG_2, ret_number, f_assert_equal},
--- 459,465 ----
{"argc", 0, 1, 0, ret_number, f_argc},
{"argidx", 0, 0, 0, ret_number, f_argidx},
{"arglistid", 0, 2, 0, ret_number, f_arglistid},
! {"argv", 0, 2, 0, ret_argv, f_argv},
{"asin", 1, 1, FEARG_1, ret_float, FLOAT_FUNC(f_asin)},
{"assert_beeps", 1, 2, FEARG_1, ret_number, f_assert_beeps},
{"assert_equal", 2, 3, FEARG_2, ret_number, f_assert_equal},
*** ../vim-8.2.1135/src/testdir/test_vim9_func.vim 2020-07-05
16:07:18.605112076 +0200
--- src/testdir/test_vim9_func.vim 2020-07-05 17:02:28.360089018 +0200
***************
*** 610,615 ****
--- 610,624 ----
assert_equal(6, res)
enddef
+ def Test_argv_return_type()
+ next fileone filetwo
+ let res = ''
+ for name in argv()
+ res ..= name
+ endfor
+ assert_equal('fileonefiletwo', res)
+ enddef
+
def Test_func_type_part()
let RefVoid: func: void
RefVoid = FuncNoArgNoRet
*** ../vim-8.2.1135/src/version.c 2020-07-05 16:51:23.610238546 +0200
--- src/version.c 2020-07-05 17:01:26.244284661 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1136,
/**/
--
BEDEVERE: And that, my lord, is how we know the Earth to be banana-shaped.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// 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/202007051504.065F4ktQ592621%40masaka.moolenaar.net.