mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Problem: Vim9: no proper error for lambda missing return type. Solution: Check for this error. (closes #7758)
This commit is contained in:
parent
e507ff15d5
commit
0346b799fc
@ -349,3 +349,5 @@ EXTERN char e_cannot_define_autocommands_for_all_events[]
|
|||||||
INIT(= N_("E1155: Cannot define autocommands for ALL events"));
|
INIT(= N_("E1155: Cannot define autocommands for ALL events"));
|
||||||
EXTERN char e_cannot_change_arglist_recursively[]
|
EXTERN char e_cannot_change_arglist_recursively[]
|
||||||
INIT(= N_("E1156: Cannot change the argument list recursively"));
|
INIT(= N_("E1156: Cannot change the argument list recursively"));
|
||||||
|
EXTERN char e_missing_return_type[]
|
||||||
|
INIT(= N_("E1157: Missing return type"));
|
||||||
|
@ -687,6 +687,13 @@ def Test_call_lambda_args()
|
|||||||
CheckDefAndScriptFailure(lines, 'E1012:')
|
CheckDefAndScriptFailure(lines, 'E1012:')
|
||||||
enddef
|
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()
|
def Test_lambda_uses_assigned_var()
|
||||||
CheckDefSuccess([
|
CheckDefSuccess([
|
||||||
'var x: any = "aaa"'
|
'var x: any = "aaa"'
|
||||||
|
@ -491,6 +491,11 @@ skip_arrow(
|
|||||||
s = skipwhite(s + 1);
|
s = skipwhite(s + 1);
|
||||||
*ret_type = s;
|
*ret_type = s;
|
||||||
s = skip_type(s, TRUE);
|
s = skip_type(s, TRUE);
|
||||||
|
if (s == *ret_type)
|
||||||
|
{
|
||||||
|
emsg(_(e_missing_return_type));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bef = s;
|
bef = s;
|
||||||
s = skipwhite(s);
|
s = skipwhite(s);
|
||||||
@ -543,6 +548,7 @@ get_lambda_tv(
|
|||||||
char_u *tofree2 = NULL;
|
char_u *tofree2 = NULL;
|
||||||
int equal_arrow = **arg == '(';
|
int equal_arrow = **arg == '(';
|
||||||
int white_error = FALSE;
|
int white_error = FALSE;
|
||||||
|
int called_emsg_start = called_emsg;
|
||||||
|
|
||||||
if (equal_arrow && !in_vim9script())
|
if (equal_arrow && !in_vim9script())
|
||||||
return NOTDONE;
|
return NOTDONE;
|
||||||
@ -560,7 +566,7 @@ get_lambda_tv(
|
|||||||
{
|
{
|
||||||
if (types_optional)
|
if (types_optional)
|
||||||
ga_clear_strings(&argtypes);
|
ga_clear_strings(&argtypes);
|
||||||
return NOTDONE;
|
return called_emsg == called_emsg_start ? NOTDONE : FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the arguments for real.
|
// Parse the arguments for real.
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2445,
|
||||||
/**/
|
/**/
|
||||||
2444,
|
2444,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user