]> granicus.if.org Git - vim/commitdiff
patch 8.2.1133: Vim9: return type of add() is not specific enough v8.2.1133
authorBram Moolenaar <Bram@vim.org>
Sun, 5 Jul 2020 14:07:21 +0000 (16:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 5 Jul 2020 14:07:21 +0000 (16:07 +0200)
Problem:    Vim9: return type of add() is not specific enough.
Solution:   Return the type of the first argument. (closes #6395)

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

index 2cdf186be33de780bb65253a76fc118b0a006745..c3eaef2ea574f915d2f15a6cd02ba7f9960c934d 100644 (file)
@@ -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},
index e8d712f0a741706dec6d376ef3d44fbc87321558..cc938a50ef79bb99ebacd158b32985588bb835e3 100644 (file)
@@ -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()
index ed3f34ad4dbe603e680cd83cad0c23a6af5b176c..6a2295191e36f0fb09c3869bfdccd0fa66e84c78 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1133,
 /**/
     1132,
 /**/