Problem: Vim9: locked script variable can be changed.
Solution: Check for locked value. (closes #8031)
CheckScriptFailure(lines, 'E741:')
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
vim9script
def SetGlobalConst()
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2692,
/**/
2691,
/**/
if (sv == NULL)
goto failed;
--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);
*sv->sv_tv = *STACK_TV_BOT(0);
}