patch 9.1.1884: :defer an empty lambda causes a crash

Commit: 
https://github.com/vim/vim/commit/f09ff72d48423d569a0fd3ed299ff80bfeeca0a2
Author: Yegappan Lakshmanan <[email protected]>
Date:   Tue Oct 28 20:05:13 2025 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 0134956c3..8de7bd357 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 c34ae0734..e225e9439 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 684d2ee66..d06759e80 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
     {

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vDqKS-008NIM-0t%40256bit.org.

Raspunde prin e-mail lui