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

patch 8.2.2760: Vim9: no error for changing a for loop variable

Problem:    Vim9: no error for changing a for loop variable.
Solution:   Make the loop variable read-only. (issue #8102)
This commit is contained in:
Bram Moolenaar
2021-04-13 21:48:03 +02:00
parent f2253963c2
commit f6a8d420a8
6 changed files with 41 additions and 12 deletions

View File

@@ -2393,6 +2393,14 @@ def Test_for_loop_fails()
g:adict = {a: 1}
CheckDefExecFailure(['for i in g:adict', 'echo 3', 'endfor'], 'E1177: For loop on dict not supported')
unlet g:adict
var lines =<< trim END
var d: list<dict<any>> = [{a: 0}]
for e in d
e = {a: 0, b: ''}
endfor
END
CheckDefAndScriptFailure2(lines, 'E1018:', 'E46:', 3)
enddef
def Test_for_loop_script_var()