1
0
forked from aniani/vim

patch 8.2.1355: Vim9: no error using :let for options and registers

Problem:    Vim9: no error using :let for options and registers.
Solution:   Give an error. (closes #6568)
This commit is contained in:
Bram Moolenaar
2020-08-02 16:59:00 +02:00
parent aa970abd0a
commit c2ee44cc38
4 changed files with 36 additions and 48 deletions

View File

@@ -5067,7 +5067,12 @@ vim9_declare_error(char_u *name)
case 'w': scope = _("window"); break;
case 't': scope = _("tab"); break;
case 'v': scope = "v:"; break;
case '$': semsg(_(e_declare_env_var), name); return;
case '$': semsg(_(e_declare_env_var), name);
return;
case '&': semsg(_("E1052: Cannot declare an option: %s"), name);
return;
case '@': semsg(_("E1066: Cannot declare a register: %s"), name);
return;
default: return;
}
semsg(_(e_declare_var), scope, name);
@@ -5229,6 +5234,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
if (cctx->ctx_skip != SKIP_YES)
{
int declare_error = FALSE;
if (*var_start == '&')
{
int cc;
@@ -5240,11 +5247,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
emsg(_(e_const_option));
goto theend;
}
if (is_decl)
{
semsg(_("E1052: Cannot declare an option: %s"), var_start);
goto theend;
}
declare_error = is_decl;
p = var_start;
p = find_option_end(&p, &opt_flags);
if (p == NULL)
@@ -5272,11 +5275,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
{
dest = dest_env;
type = &t_string;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (*var_start == '@')
{
@@ -5287,47 +5286,27 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
}
dest = dest_reg;
type = &t_string;
if (is_decl)
{
semsg(_("E1066: Cannot declare a register: %s"), name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "g:", 2) == 0)
{
dest = dest_global;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "b:", 2) == 0)
{
dest = dest_buffer;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "w:", 2) == 0)
{
dest = dest_window;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "t:", 2) == 0)
{
dest = dest_tab;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "v:", 2) == 0)
{
@@ -5346,11 +5325,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
dest = dest_vimvar;
vtv = get_vim_var_tv(vimvaridx);
type = typval2type_vimvar(vtv, cctx->ctx_type_list);
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else
{
@@ -5439,6 +5414,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
goto theend;
}
}
if (declare_error)
{
vim9_declare_error(name);
goto theend;
}
}
// handle "a:name" as a name, not index "name" on "a"