Patch 8.2.2445
Problem: Vim9: no proper error for lambda missing return type.
Solution: Check for this error. (closes #7758)
Files: src/errors.h, src/userfunc.c, src/testdir/test_vim9_func.vim
*** ../vim-8.2.2444/src/errors.h 2021-01-28 17:56:06.718493438 +0100
--- src/errors.h 2021-01-31 22:07:16.828312547 +0100
***************
*** 349,351 ****
--- 349,353 ----
INIT(= N_("E1155: Cannot define autocommands for ALL events"));
EXTERN char e_cannot_change_arglist_recursively[]
INIT(= N_("E1156: Cannot change the argument list recursively"));
+ EXTERN char e_missing_return_type[]
+ INIT(= N_("E1157: Missing return type"));
*** ../vim-8.2.2444/src/userfunc.c 2021-01-24 21:14:17.312631037 +0100
--- src/userfunc.c 2021-01-31 22:17:01.118113676 +0100
***************
*** 491,496 ****
--- 491,501 ----
s = skipwhite(s + 1);
*ret_type = s;
s = skip_type(s, TRUE);
+ if (s == *ret_type)
+ {
+ emsg(_(e_missing_return_type));
+ return NULL;
+ }
}
bef = s;
s = skipwhite(s);
***************
*** 543,548 ****
--- 548,554 ----
char_u *tofree2 = NULL;
int equal_arrow = **arg == '(';
int white_error = FALSE;
+ int called_emsg_start = called_emsg;
if (equal_arrow && !in_vim9script())
return NOTDONE;
***************
*** 560,566 ****
{
if (types_optional)
ga_clear_strings(&argtypes);
! return NOTDONE;
}
// Parse the arguments for real.
--- 566,572 ----
{
if (types_optional)
ga_clear_strings(&argtypes);
! return called_emsg == called_emsg_start ? NOTDONE : FAIL;
}
// Parse the arguments for real.
*** ../vim-8.2.2444/src/testdir/test_vim9_func.vim 2021-01-24 21:14:17.312631037 +0100
--- src/testdir/test_vim9_func.vim 2021-01-31 22:10:30.875578958 +0100
***************
*** 687,692 ****
--- 687,699 ----
CheckDefAndScriptFailure(lines, 'E1012:')
enddef
+ def Test_lambda_return_type()
+ var lines =<< trim END
+ var Ref = (): => 123
+ END
+ CheckDefAndScriptFailure(lines, 'E1157:', 1)
+ enddef
+
def Test_lambda_uses_assigned_var()
CheckDefSuccess([
'var x: any = "aaa"'
*** ../vim-8.2.2444/src/version.c 2021-01-31 21:47:39.036783041 +0100
--- src/version.c 2021-01-31 22:08:27.044046587 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2445,
/**/
--
Life would be so much easier if we could just look at the source code.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///