0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.1764: Vim9: no error when assigning to script var with wrong type

Problem:    Vim9: no error when assigning to script var with wrong type.
Solution:   Fix off-by-one error. (closes #7028)
This commit is contained in:
Bram Moolenaar 2020-09-27 21:27:40 +02:00
parent 6c542f77eb
commit 06f9c6940a
3 changed files with 13 additions and 1 deletions

View File

@ -567,6 +567,16 @@ def Test_assignment_vim9script()
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

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1764,
/**/
1763,
/**/

View File

@ -4899,7 +4899,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
{
scriptvar_idx = get_script_item_idx(scriptvar_sid,
rawname, TRUE);
if (scriptvar_idx > 0)
if (scriptvar_idx >= 0)
{
scriptitem_T *si = SCRIPT_ITEM(scriptvar_sid);
svar_T *sv =