To: vim_dev@googlegroups.com Subject: Patch 8.2.3910 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3910 Problem: When the compare function of sort() produces and error then sort() does not abort. Solution: Check if did_emsg was incremented. Files: src/list.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.3909/src/list.c 2021-12-25 21:43:24.296302789 +0000 --- src/list.c 2021-12-27 11:52:40.253651833 +0000 *************** *** 1919,1924 **** --- 1919,1925 ---- char_u *func_name; partial_T *partial = sortinfo->item_compare_partial; funcexe_T funcexe; + int did_emsg_before = did_emsg; // shortcut after failure in previous call; compare all items equal if (sortinfo->item_compare_func_err) *************** *** 1946,1952 **** clear_tv(&argv[0]); clear_tv(&argv[1]); ! if (res == FAIL) res = ITEM_COMPARE_FAIL; else { --- 1947,1953 ---- clear_tv(&argv[0]); clear_tv(&argv[1]); ! if (res == FAIL || did_emsg > did_emsg_before) res = ITEM_COMPARE_FAIL; else { *** ../vim-8.2.3909/src/testdir/test_vim9_builtin.vim 2021-12-26 17:18:10.333927753 +0000 --- src/testdir/test_vim9_builtin.vim 2021-12-27 11:50:52.113767641 +0000 *************** *** 3524,3529 **** --- 3524,3540 ---- CheckDefAndScriptFailure(['sort([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef + def Test_sort_compare_func_fails() + var lines =<< trim END + vim9script + echo ['a', 'b', 'c']->sort((a: number, b: number) => 0) + END + writefile(lines, 'Xbadsort') + assert_fails('source Xbadsort', ['E1013:', 'E702:']) + + delete('Xbadsort') + enddef + def Test_spellbadword() CheckDefAndScriptFailure(['spellbadword(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) spellbadword('good')->assert_equal(['', '']) *** ../vim-8.2.3909/src/version.c 2021-12-27 10:35:48.420658287 +0000 --- src/version.c 2021-12-27 11:41:19.242488153 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3910, /**/ -- Support your right to bare arms! Wear short sleeves! /// 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 ///