0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

patch 8.2.3890: Vim9: type check for using v: variables is basic

Problem:    Vim9: type check for using v: variables is basic.
Solution:   Specify a more precise type.
This commit is contained in:
Bram Moolenaar
2021-12-24 21:36:12 +00:00
parent e7f4abd38b
commit d787e40fdb
5 changed files with 141 additions and 117 deletions

View File

@@ -1821,8 +1821,21 @@ def Test_expr7_string()
enddef
def Test_expr7_vimvar()
v:errors = []
var errs: list<string> = v:errors
CheckDefFailure(['var errs: list<number> = v:errors'], 'E1012:')
var old: list<string> = v:oldfiles
var compl: dict<any> = v:completed_item
CheckDefFailure(['var old: list<number> = v:oldfiles'], 'E1012:')
var compl: dict<string> = v:completed_item
CheckDefFailure(['var compl: dict<number> = v:completed_item'], 'E1012:')
var args: list<string> = v:argv
CheckDefFailure(['var args: list<number> = v:argv'], 'E1012:')
var colors: dict<string> = v:colornames
CheckDefFailure(['var colors: dict<number> = v:colornames'], 'E1012:')
CheckDefFailure(["var old: list<number> = v:oldfiles"], 'E1012: Type mismatch; expected list<number> but got list<string>', 1)
CheckScriptFailure(['vim9script', 'v:oldfiles = ["foo"]', "var old: list<number> = v:oldfiles"], 'E1012: Type mismatch; expected list<number> but got list<string>', 3)