# HG changeset patch # User Bram Moolenaar # Date 1593958504 -7200 # Node ID 4a190861f0cc4e16368bb5c983548c2e50e2aadc # Parent d0940ed3e5e1e7ef7ca77e9baa066d727a104e51 patch 8.2.1133: Vim9: return type of add() is not specific enough Commit: https://github.com/vim/vim/commit/fce82b3aa7dd87f9e15a4c12eda2c65de285d99a Author: Bram Moolenaar 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) diff --git a/src/evalfunc.c b/src/evalfunc.c --- 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}, diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- 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() diff --git a/src/version.c b/src/version.c --- 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,