Mercurial > vim
comparison src/testdir/test_vim9_func.vim @ 27519:7898c7847293 v8.2.4287
patch 8.2.4287: cannot assign empty list with type to variable with list type
Commit: https://github.com/vim/vim/commit/2d3ac2e03093c4b0ae5d18c5f2f51ae0c2a9ec72
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 3 12:34:05 2022 +0000
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 03 Feb 2022 13:45:03 +0100 |
parents | 55613f0d59bc |
children | 0b12dd90a5d6 |
comparison
equal
deleted
inserted
replaced
27518:67c5f3cebf28 | 27519:7898c7847293 |
---|---|
3459 enddef | 3459 enddef |
3460 def Bar(ll: list<dict<any>>) | 3460 def Bar(ll: list<dict<any>>) |
3461 enddef | 3461 enddef |
3462 Foo() | 3462 Foo() |
3463 END | 3463 END |
3464 # "any" could be "dict<any>", thus OK | |
3464 lines[2] = 'var l: list<any>' | 3465 lines[2] = 'var l: list<any>' |
3465 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<any>', 2) | 3466 v9.CheckScriptSuccess(lines) |
3466 | |
3467 lines[2] = 'var l: list<any> = []' | 3467 lines[2] = 'var l: list<any> = []' |
3468 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<any>', 2) | 3468 v9.CheckScriptSuccess(lines) |
3469 | 3469 |
3470 lines[2] = 'var l: list<any> = [11]' | 3470 lines[2] = 'var l: list<any> = [11]' |
3471 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<number>', 2) | 3471 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<number>', 2) |
3472 enddef | 3472 enddef |
3473 | 3473 |