0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.2.2184: Vim9: no error when using "2" for a line number

Problem:    Vim9: no error when using "2" for a line number.
Solution:   Give an error message if the line number is invalid. (closes #7492)
This commit is contained in:
Bram Moolenaar
2020-12-21 21:58:46 +01:00
parent 60f63100b9
commit 9a963377b4
5 changed files with 21 additions and 3 deletions

View File

@@ -1536,11 +1536,11 @@ eval_env_var(char_u **arg, typval_T *rettv, int evaluate)
linenr_T
tv_get_lnum(typval_T *argvars)
{
linenr_T lnum = 0;
linenr_T lnum = -1;
if (argvars[0].v_type != VAR_STRING || !in_vim9script())
lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL);
if (lnum == 0) // no valid number, try using arg like line()
if (lnum <= 0) // no valid number, try using arg like line()
{
int fnum;
pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum);