0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.4500: Vim9: can declare a global variable on the command line

Problem:    Vim9: can declare a global variable on the command line.
Solution:   Disallow declaring a variable on the command line. (closes #9881)
This commit is contained in:
Bram Moolenaar
2022-03-03 17:05:35 +00:00
parent 28bf649a57
commit 0e1574c406
6 changed files with 47 additions and 34 deletions

View File

@@ -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.