# HG changeset patch # User Bram Moolenaar # Date 1611351903 -3600 # Node ID 9092d2a4422a747fa75a3e2545319bb9435a4daa # Parent 85c8bd7cca28809eb3ba19f5ecc11f4f42bf51fc patch 8.2.2394: Vim9: min() and max() return type is "any" Commit: https://github.com/vim/vim/commit/9ae3705b6ebd45086ca13c0f93a93f943559bd15 Author: Bram Moolenaar Date: Fri Jan 22 22:31:10 2021 +0100 patch 8.2.2394: Vim9: min() and max() return type is "any" Problem: Vim9: min() and max() return type is "any". Solution: Use return type "number". (closes https://github.com/vim/vim/issues/7728) diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1219,7 +1219,7 @@ static funcentry_T global_functions[] = {"matchstrpos", 2, 4, FEARG_1, NULL, ret_list_any, f_matchstrpos}, {"max", 1, 1, FEARG_1, NULL, - ret_any, f_max}, + ret_number, f_max}, {"menu_info", 1, 2, FEARG_1, NULL, ret_dict_any, #ifdef FEAT_MENU @@ -1229,7 +1229,7 @@ static funcentry_T global_functions[] = #endif }, {"min", 1, 1, FEARG_1, NULL, - ret_any, f_min}, + ret_number, f_min}, {"mkdir", 1, 3, FEARG_1, NULL, ret_number_bool, f_mkdir}, {"mode", 0, 1, FEARG_1, NULL, diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -655,6 +655,34 @@ def Test_maparg_mapset() nunmap enddef +def Test_max() + g:flag = true + var l1: list = g:flag + ? [1, max([2, 3])] + : [4, 5] + assert_equal([1, 3], l1) + + g:flag = false + var l2: list = g:flag + ? [1, max([2, 3])] + : [4, 5] + assert_equal([4, 5], l2) +enddef + +def Test_min() + g:flag = true + var l1: list = g:flag + ? [1, min([2, 3])] + : [4, 5] + assert_equal([1, 2], l1) + + g:flag = false + var l2: list = g:flag + ? [1, min([2, 3])] + : [4, 5] + assert_equal([4, 5], l2) +enddef + def Test_nr2char() nr2char(97, true)->assert_equal('a') enddef diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2394, +/**/ 2393, /**/ 2392,