Patch 8.2.3338
Problem: Vim9: no type check when assigning a list range. (Naohiro Ono)
Solution: Check the member type. (closes #8750)
Files: src/list.c, src/testdir/test_listdict.vim
*** ../vim-8.2.3337/src/list.c 2021-08-12 21:12:52.899143984 +0200
--- src/list.c 2021-08-13 18:14:06.055272805 +0200
***************
*** 852,857 ****
--- 852,858 ----
long idx1 = idx1_arg;
listitem_T *first_li = list_find_index(dest, &idx1);
long idx;
+ type_T *member_type = NULL;
/*
* Check whether any of the list items is locked before making any
changes.
***************
*** 869,874 ****
--- 870,879 ----
++idx;
}
+ if (in_vim9script() && dest->lv_type != NULL
+ && dest->lv_type->tt_member != NULL)
+ member_type = dest->lv_type->tt_member;
+
/*
* Assign the List values to the list items.
*/
***************
*** 880,885 ****
--- 885,894 ----
tv_op(&dest_li->li_tv, &src_li->li_tv, op);
else
{
+ if (member_type != NULL
+ && check_typval_arg_type(member_type, &src_li->li_tv,
+ NULL, 0) == FAIL)
+ return FAIL;
clear_tv(&dest_li->li_tv);
copy_tv(&src_li->li_tv, &dest_li->li_tv);
}
*** ../vim-8.2.3337/src/testdir/test_listdict.vim 2021-08-12
21:12:52.899143984 +0200
--- src/testdir/test_listdict.vim 2021-08-13 18:16:15.546966073 +0200
***************
*** 189,194 ****
--- 189,200 ----
call assert_equal([5, 6], l)
END
call CheckLegacyAndVim9Success(lines)
+
+ let lines =<< trim END
+ var l = [7]
+ l[:] = ['text']
+ END
+ call CheckDefAndScriptFailure(lines, 'E1012:', 2)
endfunc
" Test removing items in list
*** ../vim-8.2.3337/src/version.c 2021-08-13 17:48:19.182894928 +0200
--- src/version.c 2021-08-13 18:13:37.227341344 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3338,
/**/
--
TIM: To the north there lies a cave, the cave of Caerbannog, wherein, carved
in mystic runes, upon the very living rock, the last words of Olfin
Bedwere of Rheged make plain the last resting place of the most Holy
Grail.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202108131620.17DGKbNV3528775%40masaka.moolenaar.net.