changeset 27665:a6ffe874a24b v8.2.4358

patch 8.2.4358: Vim9: line number of exception is not set Commit: https://github.com/vim/vim/commit/90a57168a42048eb7e176a4f9acf607c31e8074f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 12 14:23:17 2022 +0000 patch 8.2.4358: Vim9: line number of exception is not set Problem: Vim9: line number of exception is not set. Solution: Set the line number before throwing an exception. (closes https://github.com/vim/vim/issues/9755)
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Feb 2022 15:30:03 +0100
parents 7ea1e3b0b5ca
children c86e351c8464
files src/testdir/test_vim9_script.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_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1057,6 +1057,18 @@ def Test_try_catch_skipped()
   assert_match("NEWLIST size 0\n", instr)
 enddef
 
+def Test_throw_line_number()
+  def Func()
+    eval 1 + 1
+    eval 2 + 2
+    throw 'exception'
+  enddef
+  try
+    Func()
+  catch /exception/
+    assert_match('line 3', v:throwpoint)
+  endtry
+enddef
 
 
 def Test_throw_vimscript()
--- 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 */
 /**/
+    4358,
+/**/
     4357,
 /**/
     4356,
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -3826,6 +3826,7 @@ exec_instructions(ectx_T *ectx)
 			}
 		    }
 
+		    SOURCING_LNUM = iptr->isn_lnum;
 		    if (throw_exception(tv->vval.v_string, ET_USER, NULL)
 								       == FAIL)
 		    {