]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.1144: Vim9: return type of reverse() is any v8.2.1144
authorBram Moolenaar <Bram@vim.org>
Sun, 5 Jul 2020 19:10:24 +0000 (21:10 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 5 Jul 2020 19:10:24 +0000 (21:10 +0200)
Problem:    Vim9: return type of reverse() is any.
Solution:   Use the type of the first argument.

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

index 83b878b37c57a475c5268af9fcb5b7bceaf8f59e..0a100748d921f546dbc5db1114ee63cb1845e465 100644 (file)
@@ -842,7 +842,7 @@ static funcentry_T global_functions[] =
     {"rename",         2, 2, FEARG_1,    ret_number,   f_rename},
     {"repeat",         2, 2, FEARG_1,    ret_first_arg, f_repeat},
     {"resolve",                1, 1, FEARG_1,    ret_string,   f_resolve},
-    {"reverse",                1, 1, FEARG_1,    ret_any,      f_reverse},
+    {"reverse",                1, 1, FEARG_1,    ret_first_arg, f_reverse},
     {"round",          1, 1, FEARG_1,    ret_float,    FLOAT_FUNC(f_round)},
     {"rubyeval",       1, 1, FEARG_1,    ret_any,
 #ifdef FEAT_RUBY
index 347dc819e0e0c73bef69acc1e00189eff4f675f5..de30a620d14361841841a4a02e76f102112c0a70 100644 (file)
@@ -927,6 +927,15 @@ def Test_insert_return_type()
   assert_equal(6, res)
 enddef
 
+def Test_reverse_return_type()
+  let l = reverse([1, 2, 3])
+  let res = 0
+  for n in l
+    res += n
+  endfor
+  assert_equal(6, res)
+enddef
+
 def Test_remove_return_type()
   let l = remove(#{one: [1, 2], two: [3, 4]}, 'one')
   let res = 0
index 65cf985a2fa5fca49ab44062c6912ce1d99f4611..f93678388baf376fc7babe0a2e63fb3cf16a9630 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1144,
 /**/
     1143,
 /**/