changeset 29429:aeba55253de4

patch 9.0.0056: wrong line number reported when :cexpr fails in :def function Commit: https://github.com/vim/vim/commit/bd683e3a79d73e608fec0df7cee1109a27f2e70a Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 18 17:49:03 2022 +0100 patch 9.0.0056: wrong line number reported when :cexpr fails in :def function Problem: Wrong line number reported when :cexpr fails in :def function. Solution: Set line_number before executing :cexpr. (closes https://github.com/vim/vim/issues/10735)
author Bram Moolenaar <Bram@vim.org>
date Mon, 18 Jul 2022 19:00:07 +0200
parents 95e7e9f24b53
children 90565e49a13e
files src/testdir/test_vim9_func.vim src/version.c src/vim9execute.c
diffstat 3 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -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()
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    56,
+/**/
     55,
 /**/
     54,
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -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)