mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2692: Vim9: locked script variable can be changed
Problem: Vim9: locked script variable can be changed. Solution: Check for locked value. (closes #8031)
This commit is contained in:
@@ -1346,6 +1346,17 @@ def Test_var_declaration_fails()
|
|||||||
CheckScriptFailure(lines, 'E741:')
|
CheckScriptFailure(lines, 'E741:')
|
||||||
unlet g:constvar
|
unlet g:constvar
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
var name = 'one'
|
||||||
|
lockvar name
|
||||||
|
def SetLocked()
|
||||||
|
name = 'two'
|
||||||
|
enddef
|
||||||
|
SetLocked()
|
||||||
|
END
|
||||||
|
CheckScriptFailure(lines, 'E741: Value is locked: name')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def SetGlobalConst()
|
def SetGlobalConst()
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
2692,
|
||||||
/**/
|
/**/
|
||||||
2691,
|
2691,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1958,6 +1958,13 @@ call_def_function(
|
|||||||
if (sv == NULL)
|
if (sv == NULL)
|
||||||
goto failed;
|
goto failed;
|
||||||
--ectx.ec_stack.ga_len;
|
--ectx.ec_stack.ga_len;
|
||||||
|
|
||||||
|
// "const" and "final" are checked at compile time, locking
|
||||||
|
// the value needs to be checked here.
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
|
if (value_check_lock(sv->sv_tv->v_lock, sv->sv_name, FALSE))
|
||||||
|
goto on_error;
|
||||||
|
|
||||||
clear_tv(sv->sv_tv);
|
clear_tv(sv->sv_tv);
|
||||||
*sv->sv_tv = *STACK_TV_BOT(0);
|
*sv->sv_tv = *STACK_TV_BOT(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user