mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.2.2395: Vim9: error for wrong type may report wrong line number
Problem: Vim9: error for wrong type may report wrong line number. Solution: Save and restore the line number when evaluating the expression. (closes #7727)
This commit is contained in:
@@ -838,6 +838,8 @@ ex_let(exarg_T *eap)
|
|||||||
i = FAIL;
|
i = FAIL;
|
||||||
if (has_assign || concat)
|
if (has_assign || concat)
|
||||||
{
|
{
|
||||||
|
int cur_lnum;
|
||||||
|
|
||||||
op[0] = '=';
|
op[0] = '=';
|
||||||
op[1] = NUL;
|
op[1] = NUL;
|
||||||
if (*expr != '=')
|
if (*expr != '=')
|
||||||
@@ -882,10 +884,15 @@ ex_let(exarg_T *eap)
|
|||||||
evalarg.eval_cookie = eap->cookie;
|
evalarg.eval_cookie = eap->cookie;
|
||||||
}
|
}
|
||||||
expr = skipwhite_and_linebreak(expr, &evalarg);
|
expr = skipwhite_and_linebreak(expr, &evalarg);
|
||||||
|
cur_lnum = SOURCING_LNUM;
|
||||||
i = eval0(expr, &rettv, eap, &evalarg);
|
i = eval0(expr, &rettv, eap, &evalarg);
|
||||||
if (eap->skip)
|
if (eap->skip)
|
||||||
--emsg_skip;
|
--emsg_skip;
|
||||||
clear_evalarg(&evalarg, eap);
|
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)
|
if (eap->skip)
|
||||||
{
|
{
|
||||||
|
@@ -55,6 +55,8 @@ def Test_assignment_bool()
|
|||||||
CheckDefAndScriptFailure(['var x: bool = [1]'], 'E1012:')
|
CheckDefAndScriptFailure(['var x: bool = [1]'], 'E1012:')
|
||||||
CheckDefAndScriptFailure(['var x: bool = {}'], 'E1012:')
|
CheckDefAndScriptFailure(['var x: bool = {}'], 'E1012:')
|
||||||
CheckDefAndScriptFailure(['var x: bool = "x"'], 'E1012:')
|
CheckDefAndScriptFailure(['var x: bool = "x"'], 'E1012:')
|
||||||
|
|
||||||
|
CheckDefAndScriptFailure(['var x: bool = "x"', '', 'eval 0'], 'E1012:', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_syntax()
|
def Test_syntax()
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2395,
|
||||||
/**/
|
/**/
|
||||||
2394,
|
2394,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user