Patch 8.2.1764
Problem: Vim9: no error when assigning to script var with wrong type.
Solution: Fix off-by-one error. (closes #7028)
Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.1763/src/vim9compile.c 2020-09-27 18:24:00.087276290 +0200
--- src/vim9compile.c 2020-09-27 21:26:02.982766813 +0200
***************
*** 4899,4905 ****
{
scriptvar_idx = get_script_item_idx(scriptvar_sid,
rawname, TRUE);
! if (scriptvar_idx > 0)
{
scriptitem_T *si = SCRIPT_ITEM(scriptvar_sid);
svar_T *sv =
--- 4899,4905 ----
{
scriptvar_idx = get_script_item_idx(scriptvar_sid,
rawname, TRUE);
! if (scriptvar_idx >= 0)
{
scriptitem_T *si = SCRIPT_ITEM(scriptvar_sid);
svar_T *sv =
*** ../vim-8.2.1763/src/testdir/test_vim9_assign.vim 2020-09-27 19:05:28.940098114 +0200
--- src/testdir/test_vim9_assign.vim 2020-09-27 21:27:07.042614505 +0200
***************
*** 567,572 ****
--- 567,582 ----
assert_equal(44, t)
END
CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ var n: number
+ def Func()
+ n = 'string'
+ enddef
+ defcompile
+ END
+ CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got string')
enddef
def Mess(): string
*** ../vim-8.2.1763/src/version.c 2020-09-27 21:16:41.764046891 +0200
--- src/version.c 2020-09-27 21:22:59.459197811 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1764,
/**/
--
hundred-and-one symptoms of being an internet addict:
6. You refuse to go to a vacation spot with no electricity and no phone lines.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///