diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-07-05 17:04:13 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-07-05 17:04:13 +0200 |
commit | 846178a72ca0860073d47fc0dc95f98d15f1d921 (patch) | |
tree | c889f44a375c368c8533580fe52098f1011aaecd /src/evalfunc.c | |
parent | 50788ef34947aeb1729604cd3876845afbd15e3c (diff) | |
download | vim-git-846178a72ca0860073d47fc0dc95f98d15f1d921.tar.gz |
patch 8.2.1136: Vim9: return type of argv() is always anyv8.2.1136
Problem: Vim9: return type of argv() is always any.
Solution: Use list<string> if there is no argument.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index c3eaef2ea..5215befb5 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -371,6 +371,17 @@ ret_list_or_dict_1(int argcount, type_T **argtypes UNUSED) 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,7 +459,7 @@ static funcentry_T global_functions[] = {"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}, + {"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}, |