Patch 8.2.4409

7 views
Skip to first unread message

Bram Moolenaar

unread,
Feb 17, 2022, 11:30:42 AM2/17/22
to vim...@googlegroups.com

Patch 8.2.4409
Problem: Vim9: some code not covered by tests.
Solution: Add a few more tests. Fix reported line number.
Files: src/vim9execute.c, src/testdir/test_vim9_assign.vim


*** ../vim-8.2.4408/src/vim9execute.c 2022-02-17 14:41:58.937322107 +0000
--- src/vim9execute.c 2022-02-17 16:15:23.738153442 +0000
***************
*** 1998,2009 ****
// Stack contains:
// -2 index
// -1 dict or list
if (tv_dest->v_type == VAR_DICT)
{
// unlet a dict item, index must be a string
if (tv_idx->v_type != VAR_STRING && tv_idx->v_type != VAR_NUMBER)
{
- SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_expected_str_but_got_str),
vartype_name(VAR_STRING),
vartype_name(tv_idx->v_type));
--- 1998,2009 ----
// Stack contains:
// -2 index
// -1 dict or list
+ SOURCING_LNUM = iptr->isn_lnum;
if (tv_dest->v_type == VAR_DICT)
{
// unlet a dict item, index must be a string
if (tv_idx->v_type != VAR_STRING && tv_idx->v_type != VAR_NUMBER)
{
semsg(_(e_expected_str_but_got_str),
vartype_name(VAR_STRING),
vartype_name(tv_idx->v_type));
***************
*** 2020,2026 ****
status = FAIL;
else
{
- SOURCING_LNUM = iptr->isn_lnum;
if (tv_idx->v_type == VAR_STRING)
{
key = tv_idx->vval.v_string;
--- 2020,2025 ----
***************
*** 2053,2059 ****
else if (tv_dest->v_type == VAR_LIST)
{
// unlet a List item, index must be a number
- SOURCING_LNUM = iptr->isn_lnum;
if (check_for_number(tv_idx) == FAIL)
{
status = FAIL;
--- 2052,2057 ----
***************
*** 2072,2078 ****

if (li == NULL)
{
- SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_list_index_out_of_range_nr), n);
status = FAIL;
}
--- 2070,2075 ----
***************
*** 2133,2139 ****
--- 2130,2140 ----

li = list_find_index(l, &n1);
if (li == NULL)
+ {
+ semsg(_(e_list_index_out_of_range_nr),
+ (long)tv_idx1->vval.v_number);
status = FAIL;
+ }
else
{
if (n1 < 0)
***************
*** 2143,2149 ****
--- 2144,2153 ----
listitem_T *li2 = list_find(l, n2);

if (li2 == NULL)
+ {
+ semsg(_(e_list_index_out_of_range_nr), n2);
status = FAIL;
+ }
else
n2 = list_idx_of_item(l, li2);
}
*** ../vim-8.2.4408/src/testdir/test_vim9_assign.vim 2022-02-17 14:41:58.937322107 +0000
--- src/testdir/test_vim9_assign.vim 2022-02-17 16:20:14.665546283 +0000
***************
*** 847,852 ****
--- 847,855 ----
assert_equal(['sdf', 'asdf', 'end'], list3)

v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:')
+ v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'unlet ll[8 : 9]'], 'E684:')
+ v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'unlet ll[1 : -9]'], 'E684:')
+ v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'unlet ll[2 : 1]'], 'E684:')

# type becomes list<any>
var somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
***************
*** 2193,2198 ****
--- 2196,2205 ----
'g:dd = {"a": 1, 2: 2}'
'unlet g:dd[0z11]',
], 'E1029:', 2)
+ v9.CheckDefExecFailure([
+ 'g:str = "a string"'
+ 'unlet g:str[0]',
+ ], 'E1148: Cannot index a string', 2)

# can compile unlet before variable exists
g:someDict = {key: 'val'}
*** ../vim-8.2.4408/src/version.c 2022-02-17 14:41:58.937322107 +0000
--- src/version.c 2022-02-17 15:04:07.862212412 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4409,
/**/

--
Time is money. Especially if you make clocks.

/// Bram Moolenaar -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages