diff options
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. |