Patch 8.2.3078
Problem:    Vim9: profile test fails.
Solution:   Make throw in :catch jump to :finally.
Files:      src/vim9compile.c, src/vim9execute.c,
            src/testdir/test_vim9_script.vim


*** ../vim-8.2.3077/src/vim9compile.c   2021-06-27 22:03:28.649707714 +0200
--- src/vim9compile.c   2021-06-30 20:34:19.938613873 +0200
***************
*** 8397,8406 ****
      this_instr = instr->ga_len;
  #ifdef FEAT_PROFILE
      if (cctx->ctx_compile_type == CT_PROFILE
!           && ((isn_T *)instr->ga_data)[instr->ga_len - 1]
                                                   .isn_type == ISN_PROF_START)
        // jump to the profile start of the "finally"
        --this_instr;
  #endif
  
      // Fill in the "end" label in jumps at the end of the blocks.
--- 8397,8413 ----
      this_instr = instr->ga_len;
  #ifdef FEAT_PROFILE
      if (cctx->ctx_compile_type == CT_PROFILE
!           && ((isn_T *)instr->ga_data)[this_instr - 1]
                                                   .isn_type == ISN_PROF_START)
+     {
        // jump to the profile start of the "finally"
        --this_instr;
+ 
+       // jump to the profile end above it
+       if (this_instr > 0 && ((isn_T *)instr->ga_data)[this_instr - 1]
+                                                    .isn_type == ISN_PROF_END)
+           --this_instr;
+     }
  #endif
  
      // Fill in the "end" label in jumps at the end of the blocks.
*** ../vim-8.2.3077/src/vim9execute.c   2021-06-30 19:54:39.442470796 +0200
--- src/vim9execute.c   2021-06-30 20:28:44.379140910 +0200
***************
*** 1577,1583 ****
            while (index > 0)
            {
                trycmd = ((trycmd_T *)trystack->ga_data) + index - 1;
!               if (!trycmd->tcd_in_catch)
                    break;
                // In the catch and finally block of this try we have to go up
                // one level.
--- 1577,1583 ----
            while (index > 0)
            {
                trycmd = ((trycmd_T *)trystack->ga_data) + index - 1;
!               if (!trycmd->tcd_in_catch || trycmd->tcd_finally_idx != 0)
                    break;
                // In the catch and finally block of this try we have to go up
                // one level.
***************
*** 1586,1594 ****
            }
            if (trycmd != NULL && trycmd->tcd_frame_idx == ectx->ec_frame_idx)
            {
!               // jump to ":catch" or ":finally"
                trycmd->tcd_in_catch = TRUE;
-               ectx->ec_iidx = trycmd->tcd_catch_idx;
                did_throw = FALSE;  // don't come back here until :endtry
                trycmd->tcd_did_throw = TRUE;
            }
--- 1586,1601 ----
            }
            if (trycmd != NULL && trycmd->tcd_frame_idx == ectx->ec_frame_idx)
            {
!               if (trycmd->tcd_in_catch)
!               {
!                   // exception inside ":catch", jump to ":finally" once
!                   ectx->ec_iidx = trycmd->tcd_finally_idx;
!                   trycmd->tcd_finally_idx = 0;
!               }
!               else
!                   // jump to first ":catch"
!                   ectx->ec_iidx = trycmd->tcd_catch_idx;
                trycmd->tcd_in_catch = TRUE;
                did_throw = FALSE;  // don't come back here until :endtry
                trycmd->tcd_did_throw = TRUE;
            }
*** ../vim-8.2.3077/src/testdir/test_vim9_script.vim    2021-06-30 
19:54:39.442470796 +0200
--- src/testdir/test_vim9_script.vim    2021-06-30 20:38:32.642196011 +0200
***************
*** 803,808 ****
--- 803,827 ----
      endtry
    endtry
    assert_equal(['1', '2', '3', '4', '5', '6'], l)
+ 
+   l = []
+   try
+     try
+       l->add('1')
+       throw 'foo'
+       l->add('x')
+     catch
+       l->add('2')
+       throw 'bar'
+       l->add('x')
+     finally
+       l->add('3')
+     endtry
+     l->add('x')
+   catch /bar/
+     l->add('4')
+   endtry
+   assert_equal(['1', '2', '3', '4'], l)
  enddef
  
  def TryOne(): number
*** ../vim-8.2.3077/src/version.c       2021-06-30 19:54:39.442470796 +0200
--- src/version.c       2021-06-30 20:35:29.098500840 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3078,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
57. You begin to wonder how on earth your service provider is allowed to call
    200 hours per month "unlimited."

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202106301839.15UIdgW41523486%40masaka.moolenaar.net.

Raspunde prin e-mail lui