comparison src/testdir/test_vim9_script.vim @ 22551:86a115a80262 v8.2.1824

patch 8.2.1824: Vim9: variables at the script level escape their scope Commit: https://github.com/vim/vim/commit/fcdc5d83fbfd7ddce634769ea902e58c87f27f20 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 10 19:07:09 2020 +0200 patch 8.2.1824: Vim9: variables at the script level escape their scope Problem: Vim9: variables at the script level escape their scope. Solution: When leaving a scope remove variables declared in it.
author Bram Moolenaar <Bram@vim.org>
date Sat, 10 Oct 2020 19:15:04 +0200
parents 35ef9b0a81a3
children 7d25264c246c
comparison
equal deleted inserted replaced
22550:d61c22faf4be 22551:86a115a80262
2683 call StopVimInTerminal(buf) 2683 call StopVimInTerminal(buf)
2684 delete('XcallFunc') 2684 delete('XcallFunc')
2685 delete('Xdidcmd') 2685 delete('Xdidcmd')
2686 enddef 2686 enddef
2687 2687
2688 def Test_script_var_scope()
2689 var lines =<< trim END
2690 vim9script
2691 if true
2692 if true
2693 var one = 'one'
2694 echo one
2695 endif
2696 echo one
2697 endif
2698 END
2699 CheckScriptFailure(lines, 'E121:', 7)
2700
2701 lines =<< trim END
2702 vim9script
2703 if true
2704 if false
2705 var one = 'one'
2706 echo one
2707 else
2708 var one = 'one'
2709 echo one
2710 endif
2711 echo one
2712 endif
2713 END
2714 CheckScriptFailure(lines, 'E121:', 10)
2715
2716 lines =<< trim END
2717 vim9script
2718 while true
2719 var one = 'one'
2720 echo one
2721 break
2722 endwhile
2723 echo one
2724 END
2725 CheckScriptFailure(lines, 'E121:', 7)
2726
2727 lines =<< trim END
2728 vim9script
2729 for i in range(1)
2730 var one = 'one'
2731 echo one
2732 endfor
2733 echo one
2734 END
2735 CheckScriptFailure(lines, 'E121:', 6)
2736 enddef
2737
2688 " Keep this last, it messes up highlighting. 2738 " Keep this last, it messes up highlighting.
2689 def Test_substitute_cmd() 2739 def Test_substitute_cmd()
2690 new 2740 new
2691 setline(1, 'something') 2741 setline(1, 'something')
2692 :substitute(some(other( 2742 :substitute(some(other(