1
0
forked from aniani/vim

patch 8.2.4287: cannot assign empty list with type to variable with list type

Problem:    Cannot assign empty list with any list type to variable with
            specific list type.
Solution:   Use unknown list type for empty list if the specified type is any.
This commit is contained in:
Bram Moolenaar
2022-02-03 12:34:05 +00:00
parent 381692b6f1
commit 2d3ac2e030
4 changed files with 19 additions and 4 deletions

View File

@@ -3461,11 +3461,11 @@ def Test_list_any_type_checked()
enddef
Foo()
END
# "any" could be "dict<any>", thus OK
lines[2] = 'var l: list<any>'
v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<any>', 2)
v9.CheckScriptSuccess(lines)
lines[2] = 'var l: list<any> = []'
v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<any>', 2)
v9.CheckScriptSuccess(lines)
lines[2] = 'var l: list<any> = [11]'
v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<number>', 2)