summaryrefslogtreecommitdiff
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-02-05 19:23:18 +0000
committerBram Moolenaar <Bram@vim.org>2022-02-05 19:23:18 +0000
commit00eb99528edc9ee1d14241d6914168fc33331ded (patch)
treedd7893d031d4e402335991f4ab1bab1102214ca2 /src/evalfunc.c
parentcd53eed2c55f2256008962965b1de1d1df76d535 (diff)
downloadvim-git-00eb99528edc9ee1d14241d6914168fc33331ded.tar.gz
patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the typev8.2.4304
Problem: Vim9: slice() makes a copy but doesn't change the type. Solution: Change the declared type like copy(). (closes #9696)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index e1dca9499..3cc95c988 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1169,6 +1169,27 @@ ret_first_arg(int argcount,
return &t_void;
}
static type_T *
+ret_slice(int argcount,
+ type2_T *argtypes,
+ type_T **decl_type)
+{
+ if (argcount > 0)
+ {
+ if (argtypes[0].type_decl != NULL)
+ {
+ switch (argtypes[0].type_decl->tt_type)
+ {
+ case VAR_STRING: *decl_type = &t_string; break;
+ case VAR_BLOB: *decl_type = &t_blob; break;
+ case VAR_LIST: *decl_type = &t_list_any; break;
+ default: break;
+ }
+ }
+ return argtypes[0].type_curr;
+ }
+ return &t_void;
+}
+ static type_T *
ret_copy(int argcount,
type2_T *argtypes,
type_T **decl_type)
@@ -2292,7 +2313,7 @@ static funcentry_T global_functions[] =
{"sinh", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_sinh)},
{"slice", 2, 3, FEARG_1, arg23_slice,
- ret_first_arg, f_slice},
+ ret_slice, f_slice},
{"sort", 1, 3, FEARG_1, arg13_sortuniq,
ret_first_arg, f_sort},
{"sound_clear", 0, 0, 0, NULL,