Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 28035:9f8535cf6f1b v8.2.4542
patch 8.2.4542: Vim9: "break" inside try/catch not handled correctly
Commit: https://github.com/vim/vim/commit/873f8243f6feadec72d9bf6203e550cc1b66611a
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 10 21:53:44 2022 +0000
patch 8.2.4542: Vim9: "break" inside try/catch not handled correctly
Problem: Vim9: "break" inside try/catch not handled correctly.
Solution: First jump to :endtry. (closes https://github.com/vim/vim/issues/9927)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 10 Mar 2022 23:00:04 +0100 |
parents | 0c84b198c678 |
children | c4ba8f3117ca |
comparison
equal
deleted
inserted
replaced
28034:c6d9d86245e2 | 28035:9f8535cf6f1b |
---|---|
903 g:sequence = '' | 903 g:sequence = '' |
904 TryContinueFunc() | 904 TryContinueFunc() |
905 assert_equal('tctc', g:sequence) | 905 assert_equal('tctc', g:sequence) |
906 unlet g:Count | 906 unlet g:Count |
907 unlet g:sequence | 907 unlet g:sequence |
908 enddef | |
909 | |
910 def Test_break_in_try_in_for() | |
911 var lines =<< trim END | |
912 vim9script | |
913 def Ls(): list<string> | |
914 var ls: list<string> | |
915 for s in ['abc', 'def'] | |
916 for _ in [123, 456] | |
917 try | |
918 eval [][0] | |
919 catch | |
920 break | |
921 endtry | |
922 endfor | |
923 ls += [s] | |
924 endfor | |
925 return ls | |
926 enddef | |
927 assert_equal(['abc', 'def'], Ls()) | |
928 END | |
929 v9.CheckScriptSuccess(lines) | |
908 enddef | 930 enddef |
909 | 931 |
910 def Test_nocatch_return_in_try() | 932 def Test_nocatch_return_in_try() |
911 # return in try block returns normally | 933 # return in try block returns normally |
912 def ReturnInTry(): string | 934 def ReturnInTry(): string |