Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 25080:146c9720e563 v8.2.3077
patch 8.2.3077: Vim9: an error in a catch block is not reported
Commit: https://github.com/vim/vim/commit/d3d8feeb897a6b956fc82c81448b938a53312d71
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 30 19:54:43 2021 +0200
patch 8.2.3077: Vim9: an error in a catch block is not reported
Problem: Vim9: an error in a catch block is not reported.
Solution: Put the "in catch" flag in the try stack. (closes https://github.com/vim/vim/issues/8478)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 30 Jun 2021 20:00:05 +0200 |
parents | eac6e5a94e9d |
children | 5c7a09cf97a1 |
comparison
equal
deleted
inserted
replaced
25079:0516203ae9c5 | 25080:146c9720e563 |
---|---|
629 DoIt() | 629 DoIt() |
630 assert_equal(['throw 1', 'catch', 'throw 2', 'done'], seq) | 630 assert_equal(['throw 1', 'catch', 'throw 2', 'done'], seq) |
631 END | 631 END |
632 enddef | 632 enddef |
633 | 633 |
634 def Test_error_in_catch() | |
635 var lines =<< trim END | |
636 try | |
637 eval [][0] | |
638 catch /E684:/ | |
639 eval [][0] | |
640 endtry | |
641 END | |
642 CheckDefExecFailure(lines, 'E684:', 4) | |
643 enddef | |
644 | |
634 " :while at the very start of a function that :continue jumps to | 645 " :while at the very start of a function that :continue jumps to |
635 def TryContinueFunc() | 646 def TryContinueFunc() |
636 while g:Count < 2 | 647 while g:Count < 2 |
637 g:sequence ..= 't' | 648 g:sequence ..= 't' |
638 try | 649 try |
766 CatchInDef() | 777 CatchInDef() |
767 assert_equal('getout', g:thrown_def) | 778 assert_equal('getout', g:thrown_def) |
768 | 779 |
769 assert_equal('intry', ReturnFinally()) | 780 assert_equal('intry', ReturnFinally()) |
770 assert_equal('finally', g:in_finally) | 781 assert_equal('finally', g:in_finally) |
782 | |
783 var l = [] | |
784 try | |
785 l->add('1') | |
786 throw 'bad' | |
787 l->add('x') | |
788 catch /bad/ | |
789 l->add('2') | |
790 try | |
791 l->add('3') | |
792 throw 'one' | |
793 l->add('x') | |
794 catch /one/ | |
795 l->add('4') | |
796 try | |
797 l->add('5') | |
798 throw 'more' | |
799 l->add('x') | |
800 catch /more/ | |
801 l->add('6') | |
802 endtry | |
803 endtry | |
804 endtry | |
805 assert_equal(['1', '2', '3', '4', '5', '6'], l) | |
771 enddef | 806 enddef |
772 | 807 |
773 def TryOne(): number | 808 def TryOne(): number |
774 try | 809 try |
775 return 0 | 810 return 0 |