]> granicus.if.org Git - vim/commitdiff
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function v8.2.1656
authorBram Moolenaar <Bram@vim.org>
Thu, 10 Sep 2020 20:05:08 +0000 (22:05 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 10 Sep 2020 20:05:08 +0000 (22:05 +0200)
Problem:    Vim9: callstack wrong if :def function calls :def function.
Solution:   Set the line number before calling. (closes #6914)

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

index ae8f329f97885eab3fa6e2695c9305bea2dea77f..4e79c89deaadfc03187becc69036e536cdf8f223 100644 (file)
@@ -1776,5 +1776,25 @@ def Test_restore_modifiers()
   assert_equal('', g:ei_after)
 enddef
 
+def StackTop()
+  eval 1
+  eval 2
+  # call not on fourth line
+  StackBot()
+enddef
+
+def StackBot()
+  # throw an error
+  eval [][0]
+enddef
+
+def Test_callstack_def()
+  try
+    StackTop()
+  catch
+    assert_match('Test_callstack_def\[2\]..StackTop\[4\]..StackBot, line 2', v:throwpoint)
+  endtry
+enddef
+
 
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
index 2628ed6100faadd0fe91d82c843d6eed52ba1c77..7aa35c2e52ae1298e7dc87736d4dd21a7b183a66 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1656,
 /**/
     1655,
 /**/
index 76cafb4c9b92d66d58f8929860b1c5b651f68d0b..18cfb0213b8ec5d5448af45aee26ed8061f63e7b 100644 (file)
@@ -1665,6 +1665,7 @@ call_def_function(
 
            // call a :def function
            case ISN_DCALL:
+               SOURCING_LNUM = iptr->isn_lnum;
                if (call_dfunc(iptr->isn_arg.dfunc.cdf_idx,
                              iptr->isn_arg.dfunc.cdf_argcount,
                              &ectx) == FAIL)