Patch 8.2.2141
Problem:    A user command with try/catch may not catch an expression error.
Solution:   When an expression fails check for following "|". (closes #7469)
Files:      src/eval.c, src/testdir/test_trycatch.vim,
            src/testdir/test_vimscript.vim


*** ../vim-8.2.2140/src/eval.c  2020-12-05 17:11:09.241679401 +0100
--- src/eval.c  2020-12-13 20:15:32.480340443 +0100
***************
*** 2158,2164 ****
            semsg(_(e_invexpr2), arg);
  
        // Some of the expression may not have been consumed.  Do not check for
!       // a next command to avoid more errors.
        return FAIL;
      }
  
--- 2158,2167 ----
            semsg(_(e_invexpr2), arg);
  
        // Some of the expression may not have been consumed.  Do not check for
!       // a next command to avoid more errors, unless "|" is following, which
!       // could only be a command separator.
!       if (eap != NULL && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|')
!           eap->nextcmd = check_nextcmd(p);
        return FAIL;
      }
  
*** ../vim-8.2.2140/src/testdir/test_trycatch.vim       2020-09-26 
17:20:49.693186820 +0200
--- src/testdir/test_trycatch.vim       2020-12-13 20:14:56.504639091 +0100
***************
*** 2199,2203 ****
--- 2199,2228 ----
    %bwipe!
  endfunc
  
+ " Test for using try/catch in a user command with a failing expression    {{{1
+ func Test_user_command_try_catch()
+   let lines =<< trim END
+       function s:throw() abort
+         throw 'error'
+       endfunction
+ 
+       command! Execute
+       \   try
+       \ |   let s:x = s:throw()
+       \ | catch
+       \ |   let g:caught = 'caught'
+       \ | endtry
+ 
+       let g:caught = 'no'
+       Execute
+       call assert_equal('caught', g:caught)
+   END
+   call writefile(lines, 'XtestTryCatch')
+   source XtestTryCatch
+ 
+   call delete('XtestTryCatch')
+   unlet g:caught
+ endfunc
+ 
  " Modeline                                                                {{{1
  " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.2140/src/testdir/test_vimscript.vim      2020-09-04 
21:18:40.492161906 +0200
--- src/testdir/test_vimscript.vim      2020-12-13 20:21:20.461844527 +0100
***************
*** 6825,6831 ****
                    \ ])
        call assert_report("Shouldn't be able to define function")
      catch
!       call assert_exception('Vim(function):E126: Missing :endfunction')
      endtry
  
      " :change
--- 6825,6831 ----
                    \ ])
        call assert_report("Shouldn't be able to define function")
      catch
!       call assert_exception('Vim(function):E1145: Missing heredoc end marker: 
.')
      endtry
  
      " :change
***************
*** 6845,6851 ****
                    \ ])
        call assert_report("Shouldn't be able to define function")
      catch
!       call assert_exception('Vim(function):E126: Missing :endfunction')
      endtry
  
      " :insert
--- 6845,6851 ----
                    \ ])
        call assert_report("Shouldn't be able to define function")
      catch
!       call assert_exception('Vim(function):E1145: Missing heredoc end marker: 
.')
      endtry
  
      " :insert
***************
*** 6865,6871 ****
                    \ ])
        call assert_report("Shouldn't be able to define function")
      catch
!       call assert_exception('Vim(function):E126: Missing :endfunction')
      endtry
  endfunc
  
--- 6865,6871 ----
                    \ ])
        call assert_report("Shouldn't be able to define function")
      catch
!       call assert_exception('Vim(function):E1145: Missing heredoc end marker: 
.')
      endtry
  endfunc
  
*** ../vim-8.2.2140/src/version.c       2020-12-13 19:22:23.924419826 +0100
--- src/version.c       2020-12-13 20:25:48.392245403 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2141,
  /**/

-- 
The most powerful force in the universe is gossip.

 /// 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/202012131926.0BDJQtAp3167997%40masaka.moolenaar.net.

Raspunde prin e-mail lui