]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.1140: Vim9: return type of extend() is any v8.2.1140
authorBram Moolenaar <Bram@vim.org>
Sun, 5 Jul 2020 18:08:39 +0000 (20:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 5 Jul 2020 18:08:39 +0000 (20:08 +0200)
Problem:    Vim9: return type of extend() is any.
Solution:   Use type of the argument.

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

index 57e707fc36431c2a82afb8b146e12b31ed86adbb..439333184b7762d9c9d9785f205c639557990d39 100644 (file)
@@ -576,7 +576,7 @@ static funcentry_T global_functions[] =
     {"exp",            1, 1, FEARG_1,    ret_float,    FLOAT_FUNC(f_exp)},
     {"expand",         1, 3, FEARG_1,    ret_any,      f_expand},
     {"expandcmd",      1, 1, FEARG_1,    ret_string,   f_expandcmd},
-    {"extend",         2, 3, FEARG_1,    ret_any,      f_extend},
+    {"extend",         2, 3, FEARG_1,    ret_first_arg, f_extend},
     {"feedkeys",       1, 2, FEARG_1,    ret_void,     f_feedkeys},
     {"file_readable",  1, 1, FEARG_1,    ret_number,   f_filereadable}, // obsolete
     {"filereadable",   1, 1, FEARG_1,    ret_number,   f_filereadable},
index d7c37b15925fee2c605fa7848aeff1052c854fab..525d46d4cd1c4d6d205c337b4af9b55c462c56b6 100644 (file)
@@ -909,6 +909,15 @@ def Test_copy_return_type()
   assert_equal(6, res)
 enddef
 
+def Test_extend_return_type()
+  let l = extend([1, 2], [3])
+  let res = 0
+  for n in l
+    res += n
+  endfor
+  assert_equal(6, res)
+enddef
+
 def Line_continuation_in_def(dir: string = ''): string
     let path: string = empty(dir)
             \ ? 'empty'
index 23d2d1b974549a8c1ff096f8685ec635412fd4eb..116cb065fe87cb7c6554665023106dd31cb92fc3 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1140,
 /**/
     1139,
 /**/