comparison src/testdir/test_vim9_script.vim @ 27948:f57b8db06f26 v8.2.4499

patch 8.2.4499: Vim9: at the script level declarations leak to next block Commit: https://github.com/vim/vim/commit/28bf649a5732ffe5a47951b5e437b765cebc5b38 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 3 15:11:20 2022 +0000 patch 8.2.4499: Vim9: at the script level declarations leak to next block Problem: Vim9: at the script level declarations leak from try block to catch and finally block. Solution: End the block and start a new one. (closes #9883)
author Bram Moolenaar <Bram@vim.org>
date Thu, 03 Mar 2022 16:15:03 +0100
parents b081ba78675a
children aacc98a38cf3
comparison
equal deleted inserted replaced
27947:6516ac07cda3 27948:f57b8db06f26
759 finally 759 finally
760 endtry 760 endtry
761 endif 761 endif
762 END 762 END
763 v9.CheckDefAndScriptSuccess(lines) 763 v9.CheckDefAndScriptSuccess(lines)
764 enddef
765
766 def Test_try_var_decl()
767 var lines =<< trim END
768 vim9script
769 try
770 var in_try = 1
771 assert_equal(1, get(s:, 'in_try', -1))
772 throw "getout"
773 catch
774 var in_catch = 2
775 assert_equal(-1, get(s:, 'in_try', -1))
776 assert_equal(2, get(s:, 'in_catch', -1))
777 finally
778 var in_finally = 3
779 assert_equal(-1, get(s:, 'in_try', -1))
780 assert_equal(-1, get(s:, 'in_catch', -1))
781 assert_equal(3, get(s:, 'in_finally', -1))
782 endtry
783 assert_equal(-1, get(s:, 'in_try', -1))
784 assert_equal(-1, get(s:, 'in_catch', -1))
785 assert_equal(-1, get(s:, 'in_finally', -1))
786 END
787 v9.CheckScriptSuccess(lines)
764 enddef 788 enddef
765 789
766 def Test_try_ends_in_return() 790 def Test_try_ends_in_return()
767 var lines =<< trim END 791 var lines =<< trim END
768 vim9script 792 vim9script