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

patch 8.2.3117: Vim9: type not properly checked in for loop

Problem:    Vim9: type not properly checked in for loop.
Solution:   Have items() return a list of lists.  Add runtime type checks.
            (closes #8515)
This commit is contained in:
Bram Moolenaar
2021-07-07 21:21:30 +02:00
parent 90df4b9d42
commit efc5db5215
5 changed files with 23 additions and 3 deletions

View File

@@ -2573,6 +2573,14 @@ def Test_for_loop_fails()
endfor
END
CheckDefAndScriptFailure(lines, 'E1059:', 1)
lines =<< trim END
var d: dict<number> = {a: 1, b: 2}
for [k: job, v: job] in d->items()
echo k v
endfor
END
CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected job but got string', 2)
enddef
def Test_for_loop_script_var()