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

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

index b015f6dad14e2b8f6cfa07ae15cbcba1430a4b31..65c34cd6a014c34d81ff15d984e7cdbbd81a39ad 100644 (file)
@@ -667,7 +667,7 @@ static funcentry_T global_functions[] =
     {"inputrestore",   0, 0, 0,          ret_number,   f_inputrestore},
     {"inputsave",      0, 0, 0,          ret_number,   f_inputsave},
     {"inputsecret",    1, 2, FEARG_1,    ret_string,   f_inputsecret},
-    {"insert",         2, 3, FEARG_1,    ret_any,      f_insert},
+    {"insert",         2, 3, FEARG_1,    ret_first_arg, f_insert},
     {"interrupt",      0, 0, 0,          ret_void,     f_interrupt},
     {"invert",         1, 1, FEARG_1,    ret_number,   f_invert},
     {"isdirectory",    1, 1, FEARG_1,    ret_number,   f_isdirectory},
index 8b83d770955c821621616418bfa25acb076a7ad5..65b525706a7478bfed4241c0d9a9a966a75dbf96 100644 (file)
@@ -918,6 +918,15 @@ def Test_extend_return_type()
   assert_equal(6, res)
 enddef
 
+def Test_insert_return_type()
+  let l = insert([2, 1], 3)
+  let res = 0
+  for n in l
+    res += n
+  endfor
+  assert_equal(6, res)
+enddef
+
 def Test_filter_return_type()
   let l = filter([1, 2, 3], {-> 1})
   let res = 0
index 47d4bccd5180e00381604d648a40757a7bd7eacf..6d4d6e93bb1503f60e0a27ef286a602235388de6 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1142,
 /**/
     1141,
 /**/