To: vim_dev@googlegroups.com Subject: Patch 8.2.4590 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4590 Problem: Vim9: range type check has wrong offset. Solution: Adjust offset for CHECKTYPE. Remove other type check. Files: src/vim9compile.c, src/vim9execute.c, src/testdir/test_vim9_assign.vim *** ../vim-8.2.4589/src/vim9compile.c 2022-03-18 19:44:44.939089425 +0000 --- src/vim9compile.c 2022-03-18 21:29:20.658351900 +0000 *************** *** 1802,1808 **** { type = get_type_on_stack(cctx, 1); if (need_type(type, &t_number, ! -1, 0, cctx, FALSE, FALSE) == FAIL) return FAIL; } type = get_type_on_stack(cctx, 0); --- 1802,1808 ---- { type = get_type_on_stack(cctx, 1); if (need_type(type, &t_number, ! -2, 0, cctx, FALSE, FALSE) == FAIL) return FAIL; } type = get_type_on_stack(cctx, 0); *** ../vim-8.2.4589/src/vim9execute.c 2022-03-18 13:10:45.399445021 +0000 --- src/vim9execute.c 2022-03-18 21:38:09.257367693 +0000 *************** *** 1896,1974 **** SOURCING_LNUM = iptr->isn_lnum; if (tv_dest->v_type == VAR_LIST) { ! long n1; ! long n2; ! int error = FALSE; ! n1 = (long)tv_get_number_chk(tv_idx1, &error); ! if (error) status = FAIL; else { ! if (tv_idx2->v_type == VAR_SPECIAL ! && tv_idx2->vval.v_number == VVAL_NONE) ! n2 = list_len(tv_dest->vval.v_list) - 1; ! else ! n2 = (long)tv_get_number_chk(tv_idx2, &error); ! if (error) ! status = FAIL; // cannot happen? ! else ! { ! listitem_T *li1 = check_range_index_one( ! tv_dest->vval.v_list, &n1, FALSE); ! ! if (li1 == NULL) ! status = FAIL; ! else ! { ! status = check_range_index_two( ! tv_dest->vval.v_list, ! &n1, li1, &n2, FALSE); ! if (status != FAIL) ! status = list_assign_range( ! tv_dest->vval.v_list, ! tv->vval.v_list, ! n1, ! n2, ! tv_idx2->v_type == VAR_SPECIAL, ! (char_u *)"=", ! (char_u *)"[unknown]"); ! } ! } } } else if (tv_dest->v_type == VAR_BLOB) { varnumber_T n1; varnumber_T n2; ! int error = FALSE; ! n1 = tv_get_number_chk(tv_idx1, &error); ! if (error) ! status = FAIL; else ! { ! if (tv_idx2->v_type == VAR_SPECIAL ! && tv_idx2->vval.v_number == VVAL_NONE) ! n2 = blob_len(tv_dest->vval.v_blob) - 1; ! else ! n2 = tv_get_number_chk(tv_idx2, &error); ! if (error) ! status = FAIL; ! else ! { ! long bloblen = blob_len(tv_dest->vval.v_blob); ! if (check_blob_index(bloblen, ! n1, FALSE) == FAIL ! || check_blob_range(bloblen, ! n1, n2, FALSE) == FAIL) ! status = FAIL; ! else ! status = blob_set_range( ! tv_dest->vval.v_blob, n1, n2, tv); ! } ! } } else { --- 1896,1949 ---- SOURCING_LNUM = iptr->isn_lnum; if (tv_dest->v_type == VAR_LIST) { ! long n1; ! long n2; ! listitem_T *li1; ! n1 = (long)tv_get_number_chk(tv_idx1, NULL); ! if (tv_idx2->v_type == VAR_SPECIAL ! && tv_idx2->vval.v_number == VVAL_NONE) ! n2 = list_len(tv_dest->vval.v_list) - 1; ! else ! n2 = (long)tv_get_number_chk(tv_idx2, NULL); ! ! li1 = check_range_index_one(tv_dest->vval.v_list, &n1, FALSE); ! if (li1 == NULL) status = FAIL; else { ! status = check_range_index_two(tv_dest->vval.v_list, ! &n1, li1, &n2, FALSE); ! if (status != FAIL) ! status = list_assign_range( ! tv_dest->vval.v_list, ! tv->vval.v_list, ! n1, ! n2, ! tv_idx2->v_type == VAR_SPECIAL, ! (char_u *)"=", ! (char_u *)"[unknown]"); } } else if (tv_dest->v_type == VAR_BLOB) { varnumber_T n1; varnumber_T n2; ! long bloblen; ! n1 = tv_get_number_chk(tv_idx1, NULL); ! if (tv_idx2->v_type == VAR_SPECIAL ! && tv_idx2->vval.v_number == VVAL_NONE) ! n2 = blob_len(tv_dest->vval.v_blob) - 1; else ! n2 = tv_get_number_chk(tv_idx2, NULL); ! bloblen = blob_len(tv_dest->vval.v_blob); ! if (check_blob_index(bloblen, n1, FALSE) == FAIL ! || check_blob_range(bloblen, n1, n2, FALSE) == FAIL) ! status = FAIL; ! else ! status = blob_set_range(tv_dest->vval.v_blob, n1, n2, tv); } else { *** ../vim-8.2.4589/src/testdir/test_vim9_assign.vim 2022-03-18 19:44:44.939089425 +0000 --- src/testdir/test_vim9_assign.vim 2022-03-18 21:40:26.001110760 +0000 *************** *** 1602,1608 **** l[g:idx : 1] = [0] echo l END ! v9.CheckDefExecAndScriptFailure(lines, 'E1030: Using a String as a Number: "x"') lines =<< trim END var l = [1, 2] --- 1602,1608 ---- l[g:idx : 1] = [0] echo l END ! v9.CheckDefExecAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "x"']) lines =<< trim END var l = [1, 2] *** ../vim-8.2.4589/src/version.c 2022-03-18 19:44:44.939089425 +0000 --- src/version.c 2022-03-18 21:30:13.362254739 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4590, /**/ -- GALAHAD hurries to the door and pushes through it. As he leaves the room we CUT TO the reverse to show that he is now in a room full of bathing and romping GIRLIES, all innocent, wide-eyed and beautiful. They smile enchantingly at him as he tries to keep walking without being diverted by the lovely sights assaulting his eyeballs. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///