]> granicus.if.org Git - vim/commitdiff
patch 8.2.4178: Vim9: invalid error for return type of lambda when debugging v8.2.4178
authorBram Moolenaar <Bram@vim.org>
Sat, 22 Jan 2022 12:27:04 +0000 (12:27 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 22 Jan 2022 12:27:04 +0000 (12:27 +0000)
Problem:    Vim9: invalid error for return type of lambda when debugging.
Solution:   Do not check the return type of a lambda. (closes #9589)

src/version.c
src/vim9cmds.c

index 154b7e314a2ba50399afac7a3ba0707f43cd67c4..f273a155f822bda74fd169132e9668b2ad38053f 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4178,
 /**/
     4177,
 /**/
index 83ff6991bd725ea9bc9d7a0eca10b6807d49d5bd..27322df1c245b256de3bad94d0ac3bb41011f347 100644 (file)
@@ -2196,7 +2196,10 @@ compile_return(char_u *arg, int check_return_type, int legacy, cctx_T *cctx)
 
     if (*p != NUL && *p != '|' && *p != '\n')
     {
-       if (cctx->ctx_ufunc->uf_ret_type->tt_type == VAR_VOID)
+       // For a lambda, "return expr" is always used, also when "expr" results
+       // in a void.
+       if (cctx->ctx_ufunc->uf_ret_type->tt_type == VAR_VOID
+               && (cctx->ctx_ufunc->uf_flags & FC_LAMBDA) == 0)
        {
            emsg(_(e_returning_value_in_function_without_return_type));
            return NULL;