Patch 8.2.2096
Problem:    Vim9: command modifiers not restored after assignment.
Solution:   Jump to nextline instead of using continue.
Files:      src/vim9compile.c, src/vim9execute.c,
            src/testdir/test_vim9_func.vim


*** ../vim-8.2.2095/src/vim9compile.c   2020-12-04 19:11:53.881306962 +0100
--- src/vim9compile.c   2020-12-05 19:15:17.827957186 +0100
***************
*** 1933,1946 ****
      static int
  generate_undo_cmdmods(cctx_T *cctx)
  {
!     isn_T     *isn;
! 
!     if (cctx->ctx_has_cmdmod)
!     {
!       if ((isn = generate_instr(cctx, ISN_CMDMOD_REV)) == NULL)
!           return FAIL;
!     }
! 
      return OK;
  }
  
--- 1933,1940 ----
      static int
  generate_undo_cmdmods(cctx_T *cctx)
  {
!     if (cctx->ctx_has_cmdmod && generate_instr(cctx, ISN_CMDMOD_REV) == NULL)
!       return FAIL;
      return OK;
  }
  
***************
*** 7578,7584 ****
                        line = compile_assignment(ea.cmd, &ea, CMD_SIZE, &cctx);
                        if (line == NULL || line == ea.cmd)
                            goto erret;
!                       continue;
                    }
                }
            }
--- 7572,7578 ----
                        line = compile_assignment(ea.cmd, &ea, CMD_SIZE, &cctx);
                        if (line == NULL || line == ea.cmd)
                            goto erret;
!                       goto nextline;
                    }
                }
            }
***************
*** 7590,7596 ****
                if (line == NULL)
                    goto erret;
                if (line != ea.cmd)
!                   continue;
            }
        }
  
--- 7584,7590 ----
                if (line == NULL)
                    goto erret;
                if (line != ea.cmd)
!                   goto nextline;
            }
        }
  
***************
*** 7629,7635 ****
            if (cctx.ctx_skip == SKIP_YES)
            {
                line += STRLEN(line);
!               continue;
            }
  
            // Expression or function call.
--- 7623,7629 ----
            if (cctx.ctx_skip == SKIP_YES)
            {
                line += STRLEN(line);
!               goto nextline;
            }
  
            // Expression or function call.
*** ../vim-8.2.2095/src/vim9execute.c   2020-12-05 18:13:24.021381533 +0100
--- src/vim9execute.c   2020-12-05 18:51:52.753117614 +0100
***************
*** 2432,2437 ****
--- 2432,2438 ----
                    else
  #endif
                    {
+                       SOURCING_LNUM = iptr->isn_lnum;
                        n1 = tv_get_number_chk(tv1, &error);
                        if (error)
                            goto on_error;
*** ../vim-8.2.2095/src/testdir/test_vim9_func.vim      2020-12-05 
18:13:24.021381533 +0100
--- src/testdir/test_vim9_func.vim      2020-12-05 19:15:52.235884555 +0100
***************
*** 1784,1789 ****
--- 1784,1805 ----
    delfunc! g:Func
  enddef
  
+ def Test_continues_with_silent_error()
+   var lines =<< trim END
+       vim9script
+       g:result = 'none'
+       def Func()
+         silent!  g:result += 3
+         g:result = 'yes'
+       enddef
+       # error is silenced, function does not abort
+       Func()
+       assert_equal('yes', g:result)
+       unlet g:result
+   END
+   CheckScriptSuccess(lines)
+ enddef
+ 
  def Test_abort_even_with_silent()
    var lines =<< trim END
        vim9script
***************
*** 1792,1804 ****
          eval {-> ''}() .. '' .. {}['X']
          g:result = 'yes'
        enddef
!       sil! Func()
        assert_equal('none', g:result)
        unlet g:result
    END
    CheckScriptSuccess(lines)
  enddef
  
  def Test_dict_member_with_silent()
    var lines =<< trim END
        vim9script
--- 1808,1845 ----
          eval {-> ''}() .. '' .. {}['X']
          g:result = 'yes'
        enddef
!       silent! Func()
        assert_equal('none', g:result)
        unlet g:result
    END
    CheckScriptSuccess(lines)
  enddef
  
+ def Test_cmdmod_silent_restored()
+   var lines =<< trim END
+       vim9script
+       def Func()
+         g:result = 'none'
+         silent! g:result += 3
+         g:result = 'none'
+         g:result += 3
+       enddef
+       Func()
+   END
+   # can't use CheckScriptFailure, it ignores the :silent!
+   var fname = 'Xdefsilent'
+   writefile(lines, fname)
+   var caught = 'no'
+   try
+     exe 'source ' .. fname
+   catch /E1030:/
+     caught = 'yes'
+     assert_match('Func, line 4', v:throwpoint)
+   endtry
+   assert_equal('yes', caught)
+   delete(fname)
+ enddef
+ 
  def Test_dict_member_with_silent()
    var lines =<< trim END
        vim9script
*** ../vim-8.2.2095/src/version.c       2020-12-05 18:13:24.021381533 +0100
--- src/version.c       2020-12-05 18:45:27.538714985 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2096,
  /**/

-- 
I just planted an Algebra tree. It has square roots.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202012051817.0B5IHock881041%40masaka.moolenaar.net.

Raspunde prin e-mail lui