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)
diff --git a/src/typval.c b/src/typval.c
index affd668..df3bc92 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -1536,11 +1536,11 @@
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);