diff src/list.c @ 25182:14448e7acdb2 v8.2.3127

patch 8.2.3127: Vim9: no error when adding number to list of string Commit: https://github.com/vim/vim/commit/f32f099761e5ae0603149b305a0086e4f4627d81 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 8 20:53:40 2021 +0200 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 https://github.com/vim/vim/issues/8529)
author Bram Moolenaar <Bram@vim.org>
date Thu, 08 Jul 2021 21:00:04 +0200
parents 8f2262c72178
children 6c75baaa54ee
line wrap: on
line diff
--- a/src/list.c
+++ b/src/list.c
@@ -597,13 +597,16 @@ list_append(list_T *l, listitem_T *item)
 
 /*
  * 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);