To: vim_dev@googlegroups.com Subject: Patch 8.2.3842 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3842 Problem: Vim9: can change locked list and list items. Solution: Check that a list and list item isn't locked. Files: src/vim9execute.c, src/testdir/test_listdict.vim *** ../vim-8.2.3841/src/vim9execute.c 2021-12-17 20:15:30.448830724 +0000 --- src/vim9execute.c 2021-12-17 20:35:18.616198875 +0000 *************** *** 2898,2915 **** { list_T *l = tv_dest->vval.v_list; long n = (long)tv_idx->vval.v_number; - listitem_T *li = NULL; ! li = list_find(l, n); ! if (li == NULL) ! { ! SOURCING_LNUM = iptr->isn_lnum; ! semsg(_(e_listidx), n); status = FAIL; - } else ! // TODO: check for list or item locked ! listitem_remove(l, li); } } else --- 2898,2923 ---- { list_T *l = tv_dest->vval.v_list; long n = (long)tv_idx->vval.v_number; ! if (l != NULL && value_check_lock( ! l->lv_lock, NULL, FALSE)) status = FAIL; else ! { ! listitem_T *li = list_find(l, n); ! ! if (li == NULL) ! { ! SOURCING_LNUM = iptr->isn_lnum; ! semsg(_(e_listidx), n); ! status = FAIL; ! } ! else if (value_check_lock(li->li_tv.v_lock, ! NULL, FALSE)) ! status = FAIL; ! else ! listitem_remove(l, li); ! } } } else *** ../vim-8.2.3841/src/testdir/test_listdict.vim 2021-12-17 20:15:30.448830724 +0000 --- src/testdir/test_listdict.vim 2021-12-17 20:33:13.452343504 +0000 *************** *** 719,724 **** --- 719,725 ---- call assert_equal(expected[depth][u][1], ps) endfor endfor + " Deleting a list range should fail if the range is locked let l = [1, 2, 3, 4] lockvar l[1:2] *************** *** 848,853 **** --- 849,865 ---- call assert_fails('let l[1:2] = [0, 1]', 'E741:') call assert_equal([1, 2, 3, 4], l) unlet l + + let lines =<< trim END + def TryUnletListItem(l: list) + unlet l[0] + enddef + let l = [1, 2, 3, 4] + lockvar! l + call TryUnletListItem(l) + END + call CheckScriptFailure(lines, 'E741:') + unlet g:l endfunc " Locking part of the list *** ../vim-8.2.3841/src/version.c 2021-12-17 20:15:30.448830724 +0000 --- src/version.c 2021-12-17 20:35:13.432205004 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3842, /**/ -- ERROR 047: Keyboard not found. Press RETURN to continue. /// 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 ///