patch 8.2.1826: Vim9: cannot use a {} block at script level
Problem: Vim9: cannot use a {} block at script level.
Solution: Recognize a {} block.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 310934e..4a71989 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3222,7 +3222,7 @@
*p == '('
|| (p == eap->cmd
? (
- // "{..." is an dict expression.
+ // "{..." is a dict expression or block start.
*eap->cmd == '{'
// "'string'->func()" is an expression.
|| *eap->cmd == '\''
@@ -3234,6 +3234,12 @@
// "varname->func()" is an expression.
: (*p == '-' && p[1] == '>')))
{
+ if (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1)))
+ {
+ // "{" by itself is the start of a block.
+ eap->cmdidx = CMD_block;
+ return eap->cmd + 1;
+ }
eap->cmdidx = CMD_eval;
return eap->cmd;
}
@@ -3355,7 +3361,7 @@
}
// check for non-alpha command
- if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL)
+ if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL)
++p;
len = (int)(p - eap->cmd);
if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))