diff 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
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -907,6 +907,28 @@ def Test_continue_in_try_in_while()
   unlet g:sequence
 enddef
 
+def Test_break_in_try_in_for()
+  var lines =<< trim END
+      vim9script
+      def Ls(): list<string>
+        var ls: list<string>
+        for s in ['abc', 'def']
+          for _ in [123, 456]
+            try
+              eval [][0]
+            catch
+              break
+            endtry
+          endfor
+          ls += [s]
+        endfor
+        return ls
+      enddef
+      assert_equal(['abc', 'def'], Ls())
+  END
+  v9.CheckScriptSuccess(lines)
+enddef
+
 def Test_nocatch_return_in_try()
   # return in try block returns normally
   def ReturnInTry(): string