Patch 8.2.2395
Problem: Vim9: error for wrong type may report wrong line number.
Solution: Save and restore the line number when evaluating the expression.
(closes #7727)
Files: src/evalvars.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.2394/src/evalvars.c 2021-01-21 21:42:09.409150461 +0100
--- src/evalvars.c 2021-01-23 13:38:24.387624290 +0100
***************
*** 838,843 ****
--- 838,845 ----
i = FAIL;
if (has_assign || concat)
{
+ int cur_lnum;
+
op[0] = '=';
op[1] = NUL;
if (*expr != '=')
***************
*** 882,891 ****
--- 884,898 ----
evalarg.eval_cookie = eap->cookie;
}
expr = skipwhite_and_linebreak(expr, &evalarg);
+ cur_lnum = SOURCING_LNUM;
i = eval0(expr, &rettv, eap, &evalarg);
if (eap->skip)
--emsg_skip;
clear_evalarg(&evalarg, eap);
+
+ // Restore the line number so that any type error is given for the
+ // declaration, not the expression.
+ SOURCING_LNUM = cur_lnum;
}
if (eap->skip)
{
*** ../vim-8.2.2394/src/testdir/test_vim9_assign.vim 2021-01-21 12:34:11.441508288 +0100
--- src/testdir/test_vim9_assign.vim 2021-01-23 13:37:50.631689713 +0100
***************
*** 55,60 ****
--- 55,62 ----
CheckDefAndScriptFailure(['var x: bool = [1]'], 'E1012:')
CheckDefAndScriptFailure(['var x: bool = {}'], 'E1012:')
CheckDefAndScriptFailure(['var x: bool = "x"'], 'E1012:')
+
+ CheckDefAndScriptFailure(['var x: bool = "x"', '', 'eval 0'], 'E1012:', 1)
enddef
def Test_syntax()
*** ../vim-8.2.2394/src/version.c 2021-01-22 22:31:06.676005413 +0100
--- src/version.c 2021-01-23 13:36:25.611849826 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2395,
/**/
--
hundred-and-one symptoms of being an internet addict:
216. Your pet rock leaves home.
/// 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 ///