diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-03 17:05:35 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-03 17:05:35 +0000 |
commit | 0e1574c4069ded47c170fcd7a47a0df66693a5f4 (patch) | |
tree | f266c5d17984eca34d287a3f04bc6584a425bafe /src/evalvars.c | |
parent | 28bf649a5732ffe5a47951b5e437b765cebc5b38 (diff) | |
download | vim-git-0e1574c4069ded47c170fcd7a47a0df66693a5f4.tar.gz |
patch 8.2.4500: Vim9: can declare a global variable on the command linev8.2.4500
Problem: Vim9: can declare a global variable on the command line.
Solution: Disallow declaring a variable on the command line. (closes #9881)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index eb69d3e20..260c297b0 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -759,6 +759,11 @@ ex_var(exarg_T *eap) semsg(_(e_str_cannot_be_used_in_legacy_vim_script), ":var"); return; } + if (current_sctx.sc_sid == 0) + { + emsg(_(e_cannot_declare_variable_on_command_line)); + return; + } ex_let(eap); } @@ -3440,7 +3445,7 @@ set_var_const( if (in_vim9script() && is_export && SCRIPT_ID_VALID(current_sctx.sc_sid) && (si = SCRIPT_ITEM(current_sctx.sc_sid)) - ->sn_autoload_prefix != NULL) + ->sn_autoload_prefix != NULL) { // In a vim9 autoload script an exported variable is put in the // global namespace with the autoload prefix. |