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

patch 8.2.2195: failing tests for :const

Problem:    Failing tests for :const.
Solution:   Add missing check for ASSIGN_FINAL.
This commit is contained in:
Bram Moolenaar
2020-12-22 22:07:30 +01:00
parent 89b474dd4f
commit 1dcf55d4f1
4 changed files with 8 additions and 8 deletions

View File

@@ -1334,7 +1334,7 @@ set_var_lval(
{ {
typval_T tv; typval_T tv;
if (flags & ASSIGN_CONST) if (flags & (ASSIGN_CONST | ASSIGN_FINAL))
{ {
emsg(_(e_cannot_mod)); emsg(_(e_cannot_mod));
*endp = cc; *endp = cc;
@@ -1372,7 +1372,7 @@ set_var_lval(
listitem_T *ll_li = lp->ll_li; listitem_T *ll_li = lp->ll_li;
int ll_n1 = lp->ll_n1; int ll_n1 = lp->ll_n1;
if (flags & ASSIGN_CONST) if (flags & (ASSIGN_CONST | ASSIGN_FINAL))
{ {
emsg(_("E996: Cannot lock a range")); emsg(_("E996: Cannot lock a range"));
return; return;
@@ -1431,7 +1431,7 @@ set_var_lval(
/* /*
* Assign to a List or Dictionary item. * Assign to a List or Dictionary item.
*/ */
if (flags & ASSIGN_CONST) if (flags & (ASSIGN_CONST | ASSIGN_FINAL))
{ {
emsg(_("E996: Cannot lock a list or dict")); emsg(_("E996: Cannot lock a list or dict"));
return; return;

View File

@@ -752,9 +752,6 @@ ex_let(exarg_T *eap)
emsg(_(e_cannot_use_let_in_vim9_script)); emsg(_(e_cannot_use_let_in_vim9_script));
return; return;
} }
if (eap->cmdidx == CMD_const && !vim9script && !eap->forceit)
// In legacy Vim script ":const" works like ":final".
eap->cmdidx = CMD_final;
if (eap->cmdidx == CMD_const) if (eap->cmdidx == CMD_const)
flags |= ASSIGN_CONST; flags |= ASSIGN_CONST;
@@ -3231,7 +3228,8 @@ set_var_const(
init_tv(tv); init_tv(tv);
} }
// ":const var = val" locks the value // ":const var = value" locks the value
// ":final var = value" locks "var"
if (flags & ASSIGN_CONST) if (flags & ASSIGN_CONST)
// Like :lockvar! name: lock the value and what it contains, but only // Like :lockvar! name: lock the value and what it contains, but only
// if the reference count is up to one. That locks only literal // if the reference count is up to one. That locks only literal

View File

@@ -1032,7 +1032,7 @@ def Test_vim9script_call_fail_const()
call Change() call Change()
unlet g:Aconst unlet g:Aconst
END END
CheckScriptFailure(lines, 'E1122: Variable is locked: Aconst', 2) CheckScriptFailure(lines, 'E741: Value is locked: Aconst', 2)
enddef enddef
" Test that inside :function a Python function can be defined, :def is not " Test that inside :function a Python function can be defined, :def is not

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2195,
/**/ /**/
2194, 2194,
/**/ /**/