]> granicus.if.org Git - vim/commitdiff
patch 8.2.1138: Vim9: return type of copy() and deepcopy() is any v8.2.1138
authorBram Moolenaar <Bram@vim.org>
Sun, 5 Jul 2020 16:41:08 +0000 (18:41 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 5 Jul 2020 16:41:08 +0000 (18:41 +0200)
Problem:    Vim9: return type of copy() and deepcopy() is any.
Solution:   Use type of the argument.

src/evalfunc.c
src/testdir/test_vim9_func.vim
src/version.c

index 5215befb5a661cb55f1e9751699d80b3b46d2842..57e707fc36431c2a82afb8b146e12b31ed86adbb 100644 (file)
@@ -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},
index 761dd57252ee6b1f41db1a4ef7d6cdb6790aa6f7..94c94575f3703f6d8be83983c1d07addec164617 100644 (file)
@@ -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'
index b6ed058e1389155f38c4a51ad79b82f621d666ed..950871e9a4895117065ded3b53d2d98f28737453 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1138,
 /**/
     1137,
 /**/