diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-22 22:31:10 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-22 22:31:10 +0100 |
commit | 9ae3705b6ebd45086ca13c0f93a93f943559bd15 (patch) | |
tree | fd50afc8f9a7b33bf61683aca9e436f65957a146 | |
parent | 4bce26bb70144633713e7e8f149ba99cac511336 (diff) |
patch 8.2.2394: Vim9: min() and max() return type is "any"v8.2.2394
Problem: Vim9: min() and max() return type is "any".
Solution: Use return type "number". (closes #7728)
-rw-r--r-- | src/evalfunc.c | 4 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 28 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 32 insertions, 2 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 7f703f60b5..cc812ce336 100644 --- 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 index 06b5ecdba5..776aec0bde 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -655,6 +655,34 @@ def Test_maparg_mapset() nunmap <F3> enddef +def Test_max() + g:flag = true + var l1: list<number> = g:flag + ? [1, max([2, 3])] + : [4, 5] + assert_equal([1, 3], l1) + + g:flag = false + var l2: list<number> = g:flag + ? [1, max([2, 3])] + : [4, 5] + assert_equal([4, 5], l2) +enddef + +def Test_min() + g:flag = true + var l1: list<number> = g:flag + ? [1, min([2, 3])] + : [4, 5] + assert_equal([1, 2], l1) + + g:flag = false + var l2: list<number> = 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 index 02fd3fa49f..63fc0b33bc 100644 --- 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, |