Mercurial > vim
changeset 21174:95abb4b22905 v8.2.1138
patch 8.2.1138: Vim9: return type of copy() and deepcopy() is any
Commit: https://github.com/vim/vim/commit/a66ba01a5fbbd72375ef6982b901d6552da2414f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 5 18:41:08 2020 +0200
patch 8.2.1138: Vim9: return type of copy() and deepcopy() is any
Problem: Vim9: return type of copy() and deepcopy() is any.
Solution: Use type of the argument.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 05 Jul 2020 18:45:04 +0200 |
parents | 664223de3ed4 |
children | 380021ad2a45 |
files | src/evalfunc.c src/testdir/test_vim9_func.vim src/version.c |
diffstat | 3 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -544,7 +544,7 @@ static funcentry_T global_functions[] = {"complete_check", 0, 0, 0, ret_number, f_complete_check}, {"complete_info", 0, 1, FEARG_1, ret_dict_any, f_complete_info}, {"confirm", 1, 4, FEARG_1, ret_number, f_confirm}, - {"copy", 1, 1, FEARG_1, ret_any, f_copy}, + {"copy", 1, 1, FEARG_1, ret_first_arg, f_copy}, {"cos", 1, 1, FEARG_1, ret_float, FLOAT_FUNC(f_cos)}, {"cosh", 1, 1, FEARG_1, ret_float, FLOAT_FUNC(f_cosh)}, {"count", 2, 4, FEARG_1, ret_number, f_count}, @@ -557,7 +557,7 @@ static funcentry_T global_functions[] = NULL #endif }, - {"deepcopy", 1, 2, FEARG_1, ret_any, f_deepcopy}, + {"deepcopy", 1, 2, FEARG_1, ret_first_arg, f_deepcopy}, {"delete", 1, 2, FEARG_1, ret_number, f_delete}, {"deletebufline", 2, 3, FEARG_1, ret_number, f_deletebufline}, {"did_filetype", 0, 0, 0, ret_number, f_did_filetype},
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -893,6 +893,22 @@ def Test_getloclist_return_type() assert_equal(#{items: []}, d) enddef +def Test_copy_return_type() + let l = copy([1, 2, 3]) + let res = 0 + for n in l + res += n + endfor + assert_equal(6, res) + + let dl = deepcopy([1, 2, 3]) + res = 0 + for n in dl + res += n + endfor + assert_equal(6, res) +enddef + def Line_continuation_in_def(dir: string = ''): string let path: string = empty(dir) \ ? 'empty'