changeset 21164:4a190861f0cc v8.2.1133

patch 8.2.1133: Vim9: return type of add() is not specific enough Commit: https://github.com/vim/vim/commit/fce82b3aa7dd87f9e15a4c12eda2c65de285d99a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 5 16:07:21 2020 +0200 patch 8.2.1133: Vim9: return type of add() is not specific enough Problem: Vim9: return type of add() is not specific enough. Solution: Return the type of the first argument. (closes https://github.com/vim/vim/issues/6395)
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Jul 2020 16:15:04 +0200
parents d0940ed3e5e1
children b64bd9672ef0
files src/evalfunc.c src/testdir/test_vim9_func.vim src/version.c
diffstat 3 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -441,7 +441,7 @@ static funcentry_T global_functions[] =
 {
     {"abs",		1, 1, FEARG_1,	  ret_any,	FLOAT_FUNC(f_abs)},
     {"acos",		1, 1, FEARG_1,	  ret_float,	FLOAT_FUNC(f_acos)},
-    {"add",		2, 2, FEARG_1,	  ret_any,	f_add},
+    {"add",		2, 2, FEARG_1,	  ret_first_arg, f_add},
     {"and",		2, 2, FEARG_1,	  ret_number,	f_and},
     {"append",		2, 2, FEARG_LAST, ret_number,	f_append},
     {"appendbufline",	3, 3, FEARG_LAST, ret_number,	f_appendbufline},
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -602,6 +602,12 @@ def Test_repeat_return_type()
     res += n
   endfor
   assert_equal(3, res)
+
+  res = 0
+  for n in add([1, 2], 3)
+    res += n
+  endfor
+  assert_equal(6, res)
 enddef
 
 def Test_func_type_part()
--- 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 */
 /**/
+    1133,
+/**/
     1132,
 /**/
     1131,