changeset 21186:34667dc9207b v8.2.1144

patch 8.2.1144: Vim9: return type of reverse() is any Commit: https://github.com/vim/vim/commit/67627355accff4af4f2a7e727c77ea8df675636e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 5 21:10:24 2020 +0200 patch 8.2.1144: Vim9: return type of reverse() is any Problem: Vim9: return type of reverse() is any. Solution: Use the type of the first argument.
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Jul 2020 21:15:04 +0200
parents dfaeb84dfb9c
children bfc9b0a72673
files src/evalfunc.c src/testdir/test_vim9_func.vim src/version.c
diffstat 3 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -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
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1144,
+/**/
     1143,
 /**/
     1142,