diff src/vim9compile.c @ 23531:f39a18a42aed v8.2.2308

patch 8.2.2308: Vim9: no error when assigning lambda to funcref Commit: https://github.com/vim/vim/commit/328eac2b5d1569c57e1130ecb9f7cca733b84d78 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 7 19:23:08 2021 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Thu, 07 Jan 2021 19:30:06 +0100
parents 27ca5534a408
children 7f0fc2ab90e3
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -857,7 +857,9 @@ use_typecheck(type_T *actual, type_T *ex
 	    || (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 @@ compile_return(char_u *arg, int check_re
 	{
 	    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;
 	    }