patch 8.2.4508: Vim9: cannot assign to a global variable on the command line
Problem: Vim9: cannot assign to a global variable on the command line.
Solution: Allow using :vim9cmd for assignment on the command line.
diff --git a/src/evalvars.c b/src/evalvars.c
index 260c297..40e643b 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -754,12 +754,14 @@
void
ex_var(exarg_T *eap)
{
+ char_u *p = eap->cmd;
+
if (!in_vim9script())
{
semsg(_(e_str_cannot_be_used_in_legacy_vim_script), ":var");
return;
}
- if (current_sctx.sc_sid == 0)
+ if (current_sctx.sc_sid == 0 && checkforcmd_noparen(&p, "var", 3))
{
emsg(_(e_cannot_declare_variable_on_command_line));
return;