summaryrefslogtreecommitdiff
path: root/src/typval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-12-21 21:58:46 +0100
committerBram Moolenaar <Bram@vim.org>2020-12-21 21:58:46 +0100
commit9a963377b4811e4e0419ec8825856ff4b01331ac (patch)
tree239f319174f46000007c1ebd1ae76797e2fe7531 /src/typval.c
parent60f63100b9bc1d24b7b80c81f43cf2fc3da95987 (diff)
downloadvim-git-9a963377b4811e4e0419ec8825856ff4b01331ac.tar.gz
patch 8.2.2184: Vim9: no error when using "2" for a line numberv8.2.2184
Problem: Vim9: no error when using "2" for a line number. Solution: Give an error message if the line number is invalid. (closes #7492)
Diffstat (limited to 'src/typval.c')
-rw-r--r--src/typval.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/typval.c b/src/typval.c
index affd668e9..df3bc92a4 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -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);