patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Problem: Vim9: cannot use :command or :au with a block in a :def function.
Solution: Recognize the start of the block.
diff --git a/src/userfunc.c b/src/userfunc.c
index 045692c..01c44d4 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -903,12 +903,25 @@
--end;
if (end > p && *end == '{')
{
+ int is_block;
+
+ // check for trailing "=> {": start of an inline function
--end;
while (end > p && VIM_ISWHITE(*end))
--end;
- if (end > p + 2 && end[-1] == '=' && end[0] == '>')
+ is_block = end > p + 2 && end[-1] == '=' && end[0] == '>';
+ if (!is_block)
{
- // found trailing "=> {", start of an inline function
+ char_u *s = p;
+
+ // check for line starting with "au" for :autocmd or
+ // "com" for :command, these can use a {} block
+ is_block = checkforcmd_noparen(&s, "autocmd", 2)
+ || checkforcmd_noparen(&s, "command", 3);
+ }
+
+ if (is_block)
+ {
if (nesting == MAX_FUNC_NESTING - 1)
emsg(_(e_function_nesting_too_deep));
else