@@ -1136,6 +1136,8 @@ static argcheck_T arg23_win_execute[] = {arg_number, arg_string_or_list_string,
11361136static argcheck_T arg23_writefile [] = {arg_list_or_blob , arg_string , arg_string };
11371137static argcheck_T arg24_match_func [] = {arg_string_or_list_any , arg_string , arg_number , arg_number };
11381138
1139+ // Can be used by functions called through "f_retfunc" to create new types.
1140+ static garray_T * current_type_gap = NULL ;
11391141
11401142/*
11411143 * Functions that return the return type of a builtin function.
@@ -1438,6 +1440,29 @@ ret_finddir(int argcount,
14381440 // Depending on the count would be a string or a list of strings.
14391441 return & t_any ;
14401442}
1443+ // for values(): list of member of first argument
1444+ static type_T *
1445+ ret_list_member (int argcount ,
1446+ type2_T * argtypes ,
1447+ type_T * * decl_type )
1448+ {
1449+ if (argcount > 0 )
1450+ {
1451+ type_T * t = argtypes [0 ].type_decl ;
1452+ if (current_type_gap != NULL
1453+ && (t -> tt_type == VAR_DICT || t -> tt_type == VAR_LIST ))
1454+ t = get_list_type (t -> tt_member , current_type_gap );
1455+ else
1456+ t = & t_list_any ;
1457+ * decl_type = t ;
1458+
1459+ t = argtypes [0 ].type_curr ;
1460+ if (current_type_gap != NULL
1461+ && (t -> tt_type == VAR_DICT || t -> tt_type == VAR_LIST ))
1462+ return get_list_type (t -> tt_member , current_type_gap );
1463+ }
1464+ return & t_list_any ;
1465+ }
14411466
14421467/*
14431468 * Used for getqflist(): returns list if there is no argument, dict if there is
@@ -2759,7 +2784,7 @@ static funcentry_T global_functions[] =
27592784 {"uniq" , 1 , 3 , FEARG_1 , arg13_sortuniq ,
27602785 ret_first_arg , f_uniq },
27612786 {"values" , 1 , 1 , FEARG_1 , arg1_dict_any ,
2762- ret_list_any , f_values },
2787+ ret_list_member , f_values },
27632788 {"virtcol" , 1 , 2 , FEARG_1 , arg2_string_or_list_bool ,
27642789 ret_virtcol , f_virtcol },
27652790 {"virtcol2col" , 3 , 3 , FEARG_1 , arg3_number ,
@@ -2993,14 +3018,17 @@ internal_func_ret_type(
29933018 int idx ,
29943019 int argcount ,
29953020 type2_T * argtypes ,
2996- type_T * * decl_type )
3021+ type_T * * decl_type ,
3022+ garray_T * type_gap )
29973023{
29983024 type_T * ret ;
29993025
3026+ current_type_gap = type_gap ;
30003027 * decl_type = NULL ;
30013028 ret = global_functions [idx ].f_retfunc (argcount , argtypes , decl_type );
30023029 if (* decl_type == NULL )
30033030 * decl_type = ret ;
3031+ current_type_gap = NULL ;
30043032 return ret ;
30053033}
30063034
0 commit comments