Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 26236:9e6ddd7b91cd v8.2.3649
patch 8.2.3649: Vim9: error for variable declared in while loop
Commit: https://github.com/vim/vim/commit/7a53f29c031f54ab67a803e5e3f8cb44e4edc4bc
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 22 18:31:02 2021 +0000
patch 8.2.3649: Vim9: error for variable declared in while loop
Problem: Vim9: error for variable declared in while loop.
Solution: Do not keep the first variable. (closes https://github.com/vim/vim/issues/9191)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 22 Nov 2021 19:45:03 +0100 |
parents | 485c7c4afeb7 |
children | 14b4c778b61e |
comparison
equal
deleted
inserted
replaced
26235:f06e596b22f6 | 26236:9e6ddd7b91cd |
---|---|
3081 var s = '' | 3081 var s = '' |
3082 while s == 'x' # {comment} | 3082 while s == 'x' # {comment} |
3083 endwhile | 3083 endwhile |
3084 enddef | 3084 enddef |
3085 | 3085 |
3086 def Test_while_loop_in_script() | |
3087 var lines =<< trim END | |
3088 vim9script | |
3089 var result = '' | |
3090 var cnt = 0 | |
3091 while cnt < 3 | |
3092 var s = 'v' .. cnt | |
3093 result ..= s | |
3094 cnt += 1 | |
3095 endwhile | |
3096 assert_equal('v0v1v2', result) | |
3097 END | |
3098 CheckScriptSuccess(lines) | |
3099 enddef | |
3100 | |
3086 def Test_while_loop_fails() | 3101 def Test_while_loop_fails() |
3087 CheckDefFailure(['while xxx'], 'E1001:') | 3102 CheckDefFailure(['while xxx'], 'E1001:') |
3088 CheckDefFailure(['endwhile'], 'E588:') | 3103 CheckDefFailure(['endwhile'], 'E588:') |
3089 CheckDefFailure(['continue'], 'E586:') | 3104 CheckDefFailure(['continue'], 'E586:') |
3090 CheckDefFailure(['if true', 'continue'], 'E586:') | 3105 CheckDefFailure(['if true', 'continue'], 'E586:') |