mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1682: Vim9: const works in an unexpected way
Problem: Vim9: const works in an unexpected way. Solution: ":const" only disallows changing the variable, not the value. Make "list[0] = 9" work at the script level.
This commit is contained in:
@@ -4800,11 +4800,6 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
||||
semsg(_(e_variable_already_declared), name);
|
||||
goto theend;
|
||||
}
|
||||
else if (lvar->lv_const)
|
||||
{
|
||||
semsg(_(e_cannot_assign_to_constant), name);
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4960,6 +4955,11 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
||||
semsg(_(e_cannot_assign_to_argument), name);
|
||||
goto theend;
|
||||
}
|
||||
if (!is_decl && lvar != NULL && lvar->lv_const && !has_index)
|
||||
{
|
||||
semsg(_(e_cannot_assign_to_constant), name);
|
||||
goto theend;
|
||||
}
|
||||
|
||||
if (!heredoc)
|
||||
{
|
||||
|
Reference in New Issue
Block a user