]> granicus.if.org Git - vim/commitdiff
patch 8.2.4540: line number for error is off by one v8.2.4540
authorBram Moolenaar <Bram@vim.org>
Thu, 10 Mar 2022 20:01:50 +0000 (20:01 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 10 Mar 2022 20:01:50 +0000 (20:01 +0000)
Problem:    Line number for error is off by one.
Solution:   Remember the line number of the comparison. (closes #9923)

src/eval.c
src/testdir/test_vim9_expr.vim
src/version.c

index a48b8f8abbae1ddaf26b0574c522f5ccfed95692..1d57c38aa0d025465d86c250001239ee28a3ae00 100644 (file)
@@ -2849,6 +2849,7 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
        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, evalarg_T *evalarg)
        {
            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;
index 1d15ba462358b86c12e8630ef9a249b4b5b6ad09..0d1cbe05f4c7ef2c52dc1170730377189f97a0d7 100644 (file)
@@ -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()
index b7449325ce8a22e02291054ba2c10840bae9563d..29477906041cb92240c807545ec07e7454e0974c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4540,
 /**/
     4539,
 /**/