Mercurial > vim
diff src/evalvars.c @ 27966:80f398bfc19f v8.2.4508
patch 8.2.4508: Vim9: cannot assign to a global variable on the command line
Commit: https://github.com/vim/vim/commit/330a388e18ad6b64c3574c712db675258b0e9878
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 5 11:05:57 2022 +0000
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 05 Mar 2022 12:15:04 +0100 |
parents | aacc98a38cf3 |
children | 40c6e5f849dc |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -754,12 +754,14 @@ heredoc_get(exarg_T *eap, char_u *cmd, i 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;