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>
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.
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1884,
/**/
1883,
/**/
// 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
{