Problem: Vim9: cannot assign a lambda to a variable of type function.
Solution: Allow for assigning a partial to a variable of type function.
(Naruhiko Nishino, closes #6996)
->map({_, v -> synIDattr(v, 'name')})->len()})
END
CheckScriptSuccess(lines)
+
+ # check if assign a lambda to a variable which type is func or any.
+ lines =<< trim END
+ vim9script
+ let FuncRef = {->123}
+ assert_equal(123, FuncRef())
+ let FuncRef_Func: func = {->123}
+ assert_equal(123, FuncRef_Func())
+ let FuncRef_Any: any = {->123}
+ assert_equal(123, FuncRef_Any())
+ END
+ CheckScriptSuccess(lines)
enddef
def Test_epxr7_funcref()
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1722,
/**/
1721,
/**/
&& !(expected->tt_type == VAR_ANY && actual->tt_type != VAR_VOID))
{
- if (expected->tt_type != actual->tt_type)
+ // tt_type should match, except that a "partial" can be assigned to a
+ // variable with type "func".
+ if (!(expected->tt_type == actual->tt_type
+ || (expected->tt_type == VAR_FUNC
+ && actual->tt_type == VAR_PARTIAL)))
{
if (expected->tt_type == VAR_BOOL
&& (actual->tt_flags & TTFLAG_BOOL_OK))