From f09ff72d48423d569a0fd3ed299ff80bfeeca0a2 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Tue, 28 Oct 2025 20:05:13 +0000 Subject: [PATCH] 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 Signed-off-by: Christian Brabandt --- src/testdir/test_vim9_script.vim | 12 ++++++++++++ src/version.c | 2 ++ src/vim9cmds.c | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 0134956c30..8de7bd3579 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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. diff --git a/src/version.c b/src/version.c index c34ae07349..e225e9439b 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1884, /**/ 1883, /**/ diff --git a/src/vim9cmds.c b/src/vim9cmds.c index 684d2ee66d..d06759e80c 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -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 { -- 2.47.3