mirror of
https://github.com/vim/vim.git
synced 2025-11-13 22:54:27 -05:00
patch 9.1.1884: :defer an empty lambda causes a crash
Problem: :defer an empty lambda causes a crash
(Maxim Kim, after v9.1.1882)
Solution: Check for missing arguments (Yegappan Lakshmanan)
related: #18641
closes: #18653
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
6be154f5e6
commit
f09ff72d48
@@ -5343,6 +5343,18 @@ def Test_defer_lambda_func()
|
||||
defcompile
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E1028: Compiling :def function failed', 1)
|
||||
|
||||
# Error: lambda without arguments
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
def Foo()
|
||||
defer () => {
|
||||
}
|
||||
assert_report("shouldn't reach here")
|
||||
enddef
|
||||
defcompile
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E107: Missing parentheses: ', 1)
|
||||
enddef
|
||||
|
||||
" Test for using an non-existing type in a "for" statement.
|
||||
|
||||
@@ -729,6 +729,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1884,
|
||||
/**/
|
||||
1883,
|
||||
/**/
|
||||
|
||||
@@ -2047,7 +2047,12 @@ compile_defer(char_u *arg_start, cctx_T *cctx)
|
||||
// a lambda function
|
||||
if (compile_lambda(&arg, cctx) != OK)
|
||||
return NULL;
|
||||
paren = arg;
|
||||
paren = vim_strchr(arg, '(');
|
||||
if (paren == NULL)
|
||||
{
|
||||
semsg(_(e_missing_parenthesis_str), arg);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user