1
- *vim9.txt* For Vim version 9.0. Last change: 2023 Jun 10
1
+ *vim9.txt* For Vim version 9.0. Last change: 2023 Oct 23
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1025,8 +1025,9 @@ always converted to string: >
1025
1025
Simple types are Number, Float, Special and Bool. For other types | string() |
1026
1026
should be used.
1027
1027
*false* *true* *null* *null_blob* *null_channel*
1028
- *null_dict* *null_function* *null_job* *null_list*
1029
- *null_partial* *null_string* *E1034*
1028
+ *null_class* *null_dict* *null_function* *null_job*
1029
+ *null_list* *null_object* *null_partial* *null_string*
1030
+ *E1034*
1030
1031
In Vim9 script one can use the following predefined values: >
1031
1032
true
1032
1033
false
@@ -1468,7 +1469,7 @@ return value) results in error *E1031* *E1186* .
1468
1469
There is no array type, use list<{type} > instead. For a list constant an
1469
1470
efficient implementation is used that avoids allocating a lot of small pieces
1470
1471
of memory.
1471
- *E1005* *E1007*
1472
+ *vim9-func-declaration* *E1005* *E1007*
1472
1473
A partial and function can be declared in more or less specific ways:
1473
1474
func any kind of function reference, no type
1474
1475
checking for arguments or return value
@@ -1487,13 +1488,14 @@ func({type}) function with argument type, does not return
1487
1488
func({type} ): {type} function with argument type and return type
1488
1489
func(?{type} ) function with type of optional argument, does
1489
1490
not return a value
1490
- func (...{type} ) function with type of variable number of
1491
- arguments, does not return a value
1492
- func({type} , ?{type} , ...{type} ): {type}
1491
+ (...list< {type} > ) function with type of list for variable number
1492
+ of arguments, does not return a value
1493
+ func({type} , ?{type} , ...list< {type} > ): {type}
1493
1494
function with:
1494
1495
- type of mandatory argument
1495
1496
- type of optional argument
1496
- - type of variable number of arguments
1497
+ - type of list for variable number of
1498
+ arguments
1497
1499
- return type
1498
1500
1499
1501
If the return type is "void" the function does not return a value.
@@ -1669,6 +1671,26 @@ Same for |extend()|, use |extendnew()| instead, and for |flatten()|, use
1669
1671
| flattennew() | instead. Since | flatten() | is intended to always change the
1670
1672
type, it can not be used in Vim9 script.
1671
1673
1674
+ Assigning to a funcref with specified arguments (see | vim9-func-declaration | )
1675
+ does strict type checking of the arguments. For variable number of arguments
1676
+ the type must match: >
1677
+ var FuncRef: func(string, number, bool): number
1678
+ FuncRef = (v1: string, v2: number, v3: bool) => 777 # OK
1679
+ FuncRef = (v1: string, v2: number, v3: number) => 777 # Error!
1680
+ # variable number of arguments must have same type
1681
+ var FuncVA: func(...list<string>): number
1682
+ FuncVA = (...v: list<number>): number => v # Error!
1683
+ FuncVA = (...v: list<any>): number => v # OK, `any` runtime check
1684
+ FuncVA = (v1: string, v: string2): number => 333 # Error!
1685
+ FuncVA = (v: list<string>): number => 3 # Error!
1686
+
1687
+ If the destinataion funcref has no specified arguments, then there is no
1688
+ argument type checking: >
1689
+ var FuncUnknownArgs: func: number
1690
+ FuncUnknownArgs = (v): number => v # OK
1691
+ FuncUnknownArgs = (v1: string, v2: string): number => 3 # OK
1692
+ FuncUnknownArgs = (...v1: list<string>): number => 333 # OK
1693
+ <
1672
1694
*E1211* *E1217* *E1218* *E1219* *E1220* *E1221*
1673
1695
*E1222* *E1223* *E1224* *E1225* *E1226* *E1227*
1674
1696
*E1228* *E1238* *E1250* *E1251* *E1252* *E1256*
0 commit comments