1
0
forked from aniani/vim

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 #7728)
This commit is contained in:
Bram Moolenaar
2021-01-22 22:31:10 +01:00
parent 4bce26bb70
commit 9ae3705b6e
3 changed files with 32 additions and 2 deletions

View File

@@ -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,

View File

@@ -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

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2394,
/**/
2393,
/**/