0
0
mirror of https://github.com/vim/vim.git synced 2025-10-01 04:54:07 -04:00

patch 8.2.1145: Vim9: "for" only accepts a list at compile time

Problem:    Vim9: "for" only accepts a list at compile time.
Solution:   Also accept a list at runtime.
This commit is contained in:
Bram Moolenaar
2020-07-05 21:38:11 +02:00
parent 67627355ac
commit 0ad3e894d7
4 changed files with 50 additions and 5 deletions

View File

@@ -1440,6 +1440,12 @@ def Test_for_loop()
result ..= cnt .. '_'
endfor
assert_equal('0_1_3_', result)
let concat = ''
for str in eval('["one", "two"]')
concat ..= str
endfor
assert_equal('onetwo', concat)
enddef
def Test_for_loop_fails()
@@ -1447,7 +1453,7 @@ def Test_for_loop_fails()
CheckDefFailure(['for i In range(5)'], 'E690:')
CheckDefFailure(['let x = 5', 'for x in range(5)'], 'E1023:')
CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:')
CheckDefFailure(['for i in "text"'], 'E1024:')
CheckDefFailure(['for i in "text"'], 'E1013:')
CheckDefFailure(['for i in xxx'], 'E1001:')
CheckDefFailure(['endfor'], 'E588:')
CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:')