patch 8.2.3127: Vim9: no error when adding number to list of string
Problem: Vim9: no error when adding number to list of string.
Solution: Check the value type. (closes #8529)
diff --git a/src/list.c b/src/list.c
index 6041bd2..9aec823 100644
--- a/src/list.c
+++ b/src/list.c
@@ -597,13 +597,16 @@
/*
* Append typval_T "tv" to the end of list "l". "tv" is copied.
- * Return FAIL when out of memory.
+ * Return FAIL when out of memory or the type is wrong.
*/
int
list_append_tv(list_T *l, typval_T *tv)
{
listitem_T *li = listitem_alloc();
+ if (l->lv_type != NULL && l->lv_type->tt_member != NULL
+ && check_typval_arg_type(l->lv_type->tt_member, tv, 0) == FAIL)
+ return FAIL;
if (li == NULL)
return FAIL;
copy_tv(tv, &li->li_tv);