]> granicus.if.org Git - vim/commitdiff
patch 9.0.0056: wrong line number reported when :cexpr fails in :def function
authorBram Moolenaar <Bram@vim.org>
Mon, 18 Jul 2022 16:49:03 +0000 (17:49 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 18 Jul 2022 16:49:03 +0000 (17:49 +0100)
Problem:    Wrong line number reported when :cexpr fails in :def function.
Solution:   Set line_number before executing :cexpr. (closes #10735)

src/testdir/test_vim9_func.vim
src/version.c
src/vim9execute.c

index 33a66151e7bde895e6ddaa85a3a54b500b16ffe3..2714fa1ccfd2f6cf56f29c89b451ca9c91e38b73 100644 (file)
@@ -4205,6 +4205,18 @@ def Test_multiple_funcref()
   v9.CheckScriptSuccess(lines)
 enddef
 
+def Test_cexpr_errmsg_line_number()
+  var lines =<< trim END
+      vim9script
+      def Func()
+        var qfl = {}
+        cexpr qfl
+      enddef
+      Func()
+  END
+  v9.CheckScriptFailure(lines, 'E777', 2)
+enddef
+
 " The following messes up syntax highlight, keep near the end.
 if has('python3')
   def Test_python3_command()
index f2304f326d5fc95f6dbe37dd2e8a7c39a6db3603..87a8d10728deeedead6afe36c855a4046a5f567f 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    56,
 /**/
     55,
 /**/
index 9dd5937e47cf34986ce3954f77cd76fc59433210..2f94f05c54a7107050067da48a0b17eeb0f156c9 100644 (file)
@@ -2786,6 +2786,7 @@ exec_instructions(ectx_T *ectx)
                    ea.cmdlinep = &iptr->isn_arg.cexpr.cexpr_ref->cer_cmdline;
                    --ectx->ec_stack.ga_len;
                    tv = STACK_TV_BOT(0);
+                   SOURCING_LNUM = iptr->isn_lnum;
                    res = cexpr_core(&ea, tv);
                    clear_tv(tv);
                    if (res == FAIL)