END
CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0)
CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1)
+
+ lines =<< trim END
+ var d: dict<bool>
+ extend(d, {b: 0})
+ END
+ CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<bool> but got dict<number>', 2)
enddef
func g:ExtendList(l)
END
CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0)
CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1)
+
+ lines =<< trim END
+ var l: list<bool>
+ extend(l, [0])
+ END
+ CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<bool> but got list<number>', 2)
enddef
def Test_extend_return_type()
list_T *l = tv->vval.v_list;
listitem_T *li;
- if (l == NULL || l->lv_first == NULL)
+ if (l == NULL || (l->lv_first == NULL && l->lv_type == NULL))
return &t_list_empty;
if (!do_member)
return &t_list_any;
+ if (l->lv_type != NULL)
+ return l->lv_type;
if (l->lv_first == &range_list_item)
return &t_list_number;
if (l->lv_copyID == copyID)
typval_T *value;
dict_T *d = tv->vval.v_dict;
- if (d == NULL || d->dv_hashtab.ht_used == 0)
+ if (d == NULL || (d->dv_hashtab.ht_used == 0 && d->dv_type == NULL))
return &t_dict_empty;
if (!do_member)
return &t_dict_any;
+ if (d->dv_type != NULL)
+ return d->dv_type;
if (d->dv_copyID == copyID)
// avoid recursion
return &t_dict_any;