# HG changeset patch # User Bram Moolenaar # Date 1645116303 -3600 # Node ID 2a394907825db6706481cd3006263d2c9ce9d242 # Parent eea7436ad107334370c13e74c776636af4985a6f patch 8.2.4409: Vim9: some code not covered by tests Commit: https://github.com/vim/vim/commit/6296d1e60edf7ac150ee1707c14d4355f3220b88 Author: Bram Moolenaar Date: Thu Feb 17 16:30:11 2022 +0000 patch 8.2.4409: Vim9: some code not covered by tests Problem: Vim9: some code not covered by tests. Solution: Add a few more tests. Fix reported line number. diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -847,6 +847,9 @@ def Test_assignment_list() 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 var somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] @@ -2193,6 +2196,10 @@ def Test_unlet() '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'} diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4409, +/**/ 4408, /**/ 4407, diff --git a/src/vim9execute.c b/src/vim9execute.c --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -1998,12 +1998,12 @@ execute_unletindex(isn_T *iptr, ectx_T * // 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) { - SOURCING_LNUM = iptr->isn_lnum; semsg(_(e_expected_str_but_got_str), vartype_name(VAR_STRING), vartype_name(tv_idx->v_type)); @@ -2020,7 +2020,6 @@ execute_unletindex(isn_T *iptr, ectx_T * status = FAIL; else { - SOURCING_LNUM = iptr->isn_lnum; if (tv_idx->v_type == VAR_STRING) { key = tv_idx->vval.v_string; @@ -2053,7 +2052,6 @@ execute_unletindex(isn_T *iptr, ectx_T * 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; @@ -2072,7 +2070,6 @@ execute_unletindex(isn_T *iptr, ectx_T * if (li == NULL) { - SOURCING_LNUM = iptr->isn_lnum; semsg(_(e_list_index_out_of_range_nr), n); status = FAIL; } @@ -2133,7 +2130,11 @@ execute_unletrange(isn_T *iptr, ectx_T * 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,7 +2144,10 @@ execute_unletrange(isn_T *iptr, ectx_T * 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); }