patch 8.2.2308: Vim9: no error when assigning lambda to funcref

Problem:    Vim9: no error when assigning lambda to funcref without return
            value.
Solution:   Default return value to "any". (closes #7629)
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index 2a21ca0..2d137a3 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -1091,6 +1091,13 @@
       assert_equal(123, FuncRef_Any())
   END
   CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      var Ref: func(number)
+      Ref = (j) => !j
+  END
+  CheckDefFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(any): bool')
+  CheckScriptFailure(['vim9script'] + lines, 'E1012: Type mismatch; expected func(number) but got func(any): any')
 enddef
 
 def Test_heredoc()
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index c26f2af..9f19ebd 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1508,7 +1508,7 @@
       'delfunc g:NotExist'], 'E700:')
 enddef
 
-def RefFunc(Ref: func(string): string): string
+def RefFunc(Ref: func(any): any): string
   return Ref('more')
 enddef
 
diff --git a/src/userfunc.c b/src/userfunc.c
index 4c59bb5..814d400 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -668,7 +668,7 @@
 		    goto errret;
 	    }
 	    else
-		fp->uf_ret_type = &t_unknown;
+		fp->uf_ret_type = &t_any;
 	}
 
 	fp->uf_lines = newlines;
diff --git a/src/version.c b/src/version.c
index 3f8ed2a..f39a0d3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2308,
+/**/
     2307,
 /**/
     2306,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index c3aab20..f66b27f 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -857,7 +857,9 @@
 	    || (actual->tt_type == VAR_FUNC
 		&& (expected->tt_type == VAR_FUNC
 					   || expected->tt_type == VAR_PARTIAL)
-		&& (actual->tt_member == &t_any || actual->tt_argcount < 0)))
+		&& (actual->tt_member == &t_any || actual->tt_argcount < 0)
+		&& ((actual->tt_member == &t_void)
+					 == (expected->tt_member == &t_void))))
 	return TRUE;
     if ((actual->tt_type == VAR_LIST || actual->tt_type == VAR_DICT)
 				       && actual->tt_type == expected->tt_type)
@@ -4812,7 +4814,8 @@
 	{
 	    stack_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
 	    if (check_return_type && (cctx->ctx_ufunc->uf_ret_type == NULL
-				|| cctx->ctx_ufunc->uf_ret_type == &t_unknown))
+				|| cctx->ctx_ufunc->uf_ret_type == &t_unknown
+				|| cctx->ctx_ufunc->uf_ret_type == &t_any))
 	    {
 		cctx->ctx_ufunc->uf_ret_type = stack_type;
 	    }