To: vim_dev@googlegroups.com Subject: Patch 8.2.3127 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3127 Problem: Vim9: no error when adding number to list of string. Solution: Check the value type. (closes #8529) Files: src/list.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.3126/src/list.c 2021-06-27 22:03:28.645707721 +0200 --- src/list.c 2021-07-08 20:08:17.106445278 +0200 *************** *** 597,609 **** /* * Append typval_T "tv" to the end of list "l". "tv" is copied. ! * Return FAIL when out of memory. */ int list_append_tv(list_T *l, typval_T *tv) { listitem_T *li = listitem_alloc(); if (li == NULL) return FAIL; copy_tv(tv, &li->li_tv); --- 597,612 ---- /* * Append typval_T "tv" to the end of list "l". "tv" is copied. ! * 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); *** ../vim-8.2.3126/src/testdir/test_vim9_builtin.vim 2021-07-05 14:10:00.431729296 +0200 --- src/testdir/test_vim9_builtin.vim 2021-07-08 20:50:16.982922857 +0200 *************** *** 104,109 **** --- 104,116 ---- add(l, 123) END CheckScriptSuccess(lines) + + lines =<< trim END + vim9script + var l: list = ['a'] + l->add(123) + END + CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3) enddef def Test_add_blob() *** ../vim-8.2.3126/src/version.c 2021-07-08 19:22:09.238611461 +0200 --- src/version.c 2021-07-08 20:09:28.110323834 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3127, /**/ -- hundred-and-one symptoms of being an internet addict: 95. Only communication in your household is through email. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///