changeset 28031:4aa79224acd2 v8.2.4540

patch 8.2.4540: line number for error is off by one Commit: https://github.com/vim/vim/commit/1b1df95f1a84cbc362e32f676f1e135aa2e7fc3c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 10 20:01:50 2022 +0000 patch 8.2.4540: line number for error is off by one Problem: Line number for error is off by one. Solution: Remember the line number of the comparison. (closes https://github.com/vim/vim/issues/9923)
author Bram Moolenaar <Bram@vim.org>
date Thu, 10 Mar 2022 21:15:04 +0100
parents 7c6b90dd119e
children 8b90d89c9bdd
files src/eval.c src/testdir/test_vim9_expr.vim src/version.c
diffstat 3 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -2849,6 +2849,7 @@ eval4(char_u **arg, typval_T *rettv, eva
 	int	    vim9script = in_vim9script();
 	int	    evaluate = evalarg == NULL
 				   ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
+	long	    comp_lnum = SOURCING_LNUM;
 
 	if (getnext)
 	{
@@ -2904,6 +2905,8 @@ eval4(char_u **arg, typval_T *rettv, eva
 	{
 	    int ret;
 
+	    // use the line of the comparison for messages
+	    SOURCING_LNUM = comp_lnum;
 	    if (vim9script && check_compare_types(type, rettv, &var2) == FAIL)
 	    {
 		ret = FAIL;
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -844,6 +844,13 @@ def Test_expr4_compare_none()
   v9.CheckDefAndScriptFailure(['echo [] == v:none'], 'E1072: Cannot compare list with special')
   v9.CheckDefAndScriptFailure(['echo 123 == v:none'], 'E1072: Cannot compare number with special')
   v9.CheckDefAndScriptFailure(['echo 0z00 == v:none'], 'E1072: Cannot compare blob with special')
+
+  lines =<< trim END
+      echo [] == v:none
+
+      eval 0 + 0
+  END
+  v9.CheckDefAndScriptFailure(lines, 'E1072:', 1)
 enddef
 
 def Test_expr4_wrong_type()
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4540,
+/**/
     4539,
 /**/
     4538,