patch 8.2.3704: Vim9: cannot use a list declaration in a :def function

Problem:    Vim9: cannot use a list declaration in a :def function.
Solution:   Make it work.
This commit is contained in:
Bram Moolenaar
2021-11-30 16:14:49 +00:00
parent 53ba95e4f0
commit ab36e6ae7b
5 changed files with 66 additions and 17 deletions

View File

@ -420,12 +420,11 @@ similar to how a function argument can be ignored: >
To ignore any remaining items: >
[a, b; _] = longList
< *E1092*
Declaring more than one variable at a time, using the unpack notation, is
currently not supported: >
var [v1, v2] = GetValues() # Error!
That is because the type needs to be inferred from the list item type, which
isn't that easy.
possible. Each variable can have a type or infer it from the value: >
var [v1: number, v2] = GetValues()
Use this only when there is a list with values, declaring one variable per
line is much easier to read and change later.
Constants ~