{
// Check that map() does not change the type of the dict.
ga_init2(&type_list, sizeof(type_T *), 10);
- type = typval2type(argvars, &type_list);
+ type = typval2type(argvars, get_copyID(), &type_list);
}
if (argvars[0].v_type == VAR_BLOB)
{
// Check that map() does not change the type of the dict.
ga_init2(&type_list, sizeof(type_T *), 10);
- type = typval2type(argvars, &type_list);
+ type = typval2type(argvars, get_copyID(), &type_list);
}
if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST)
type_T *get_func_type(type_T *ret_type, int argcount, garray_T *type_gap);
int func_type_add_arg_types(type_T *functype, int argcount, garray_T *type_gap);
int need_convert_to_bool(type_T *type, typval_T *tv);
-type_T *typval2type(typval_T *tv, garray_T *type_gap);
+type_T *typval2type(typval_T *tv, int copyID, garray_T *type_gap);
type_T *typval2type_vimvar(typval_T *tv, garray_T *type_gap);
int check_typval_arg_type(type_T *expected, typval_T *actual_tv, int arg_idx);
int check_typval_type(type_T *expected, typval_T *actual_tv, where_T where);
* "type_gap" is used to temporarily create types in.
*/
static type_T *
-typval2type_int(typval_T *tv, garray_T *type_gap)
+typval2type_int(typval_T *tv, int copyID, garray_T *type_gap)
{
type_T *type;
type_T *member_type = &t_any;
return &t_list_empty;
if (l->lv_first == &range_list_item)
return &t_list_number;
+ if (l->lv_copyID == copyID)
+ // avoid recursion
+ return &t_list_any;
+ l->lv_copyID = copyID;
// Use the common type of all members.
- member_type = typval2type(&l->lv_first->li_tv, type_gap);
+ member_type = typval2type(&l->lv_first->li_tv, copyID, type_gap);
for (li = l->lv_first->li_next; li != NULL; li = li->li_next)
- common_type(typval2type(&li->li_tv, type_gap),
+ common_type(typval2type(&li->li_tv, copyID, type_gap),
member_type, &member_type, type_gap);
return get_list_type(member_type, type_gap);
}
{
dict_iterator_T iter;
typval_T *value;
+ dict_T *d = tv->vval.v_dict;
- if (tv->vval.v_dict == NULL
- || tv->vval.v_dict->dv_hashtab.ht_used == 0)
+ if (d == NULL || d->dv_hashtab.ht_used == 0)
return &t_dict_empty;
+ if (d->dv_copyID == copyID)
+ // avoid recursion
+ return &t_dict_any;
+ d->dv_copyID = copyID;
// Use the common type of all values.
dict_iterate_start(tv, &iter);
dict_iterate_next(&iter, &value);
- member_type = typval2type(value, type_gap);
+ member_type = typval2type(value, copyID, type_gap);
while (dict_iterate_next(&iter, &value) != NULL)
- common_type(typval2type(value, type_gap),
+ common_type(typval2type(value, copyID, type_gap),
member_type, &member_type, type_gap);
return get_dict_type(member_type, type_gap);
}
* "type_list" is used to temporarily create types in.
*/
type_T *
-typval2type(typval_T *tv, garray_T *type_gap)
+typval2type(typval_T *tv, int copyID, garray_T *type_gap)
{
- type_T *type = typval2type_int(tv, type_gap);
+ type_T *type = typval2type_int(tv, copyID, type_gap);
if (type != NULL && type != &t_bool
&& (tv->v_type == VAR_NUMBER
return &t_list_string;
if (tv->v_type == VAR_DICT) // e.g. for v:completed_item
return &t_dict_any;
- return typval2type(tv, type_gap);
+ return typval2type(tv, get_copyID(), type_gap);
}
int
int res = FAIL;
ga_init2(&type_list, sizeof(type_T *), 10);
- actual_type = typval2type(actual_tv, &type_list);
+ actual_type = typval2type(actual_tv, get_copyID(), &type_list);
if (actual_type != NULL)
res = check_type(expected, actual_type, TRUE, where);
clear_type_list(&type_list);
rettv->v_type = VAR_STRING;
ga_init2(&type_list, sizeof(type_T *), 10);
- type = typval2type(argvars, &type_list);
+ type = typval2type(argvars, get_copyID(), &type_list);
name = type_name(type, &tofree);
if (tofree != NULL)
rettv->vval.v_string = (char_u *)tofree;