diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-23 13:39:14 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-23 13:39:14 +0100 |
commit | 9a562c184d98d82bb7506caf2071cfe15a92fa43 (patch) | |
tree | a88dbd515d2b8dca397912fc230573b0ed0f5c5f /src/evalvars.c | |
parent | 9ae3705b6ebd45086ca13c0f93a93f943559bd15 (diff) |
patch 8.2.2395: Vim9: error for wrong type may report wrong line numberv8.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)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index dfc8e63f5a..b6a6927d60 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -838,6 +838,8 @@ ex_let(exarg_T *eap) i = FAIL; if (has_assign || concat) { + int cur_lnum; + op[0] = '='; op[1] = NUL; if (*expr != '=') @@ -882,10 +884,15 @@ ex_let(exarg_T *eap) 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) { |