mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.2193: Vim9: can change constant in :def function
Problem: Vim9: can change constant in :def function. Solution: Check if a variable is locked. (issue #7526)
This commit is contained in:
@@ -3125,13 +3125,7 @@ set_var_const(
|
||||
goto failed;
|
||||
}
|
||||
|
||||
// Check in this order for backwards compatibility:
|
||||
// - Whether the variable is read-only
|
||||
// - Whether the variable value is locked
|
||||
// - Whether the variable is locked
|
||||
if (var_check_ro(di->di_flags, name, FALSE)
|
||||
|| value_check_lock(di->di_tv.v_lock, name, FALSE)
|
||||
|| var_check_lock(di->di_flags, name, FALSE))
|
||||
if (var_check_permission(di, name) == FAIL)
|
||||
goto failed;
|
||||
}
|
||||
else
|
||||
@@ -3242,6 +3236,22 @@ failed:
|
||||
clear_tv(tv_arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check in this order for backwards compatibility:
|
||||
* - Whether the variable is read-only
|
||||
* - Whether the variable value is locked
|
||||
* - Whether the variable is locked
|
||||
*/
|
||||
int
|
||||
var_check_permission(dictitem_T *di, char_u *name)
|
||||
{
|
||||
if (var_check_ro(di->di_flags, name, FALSE)
|
||||
|| value_check_lock(di->di_tv.v_lock, name, FALSE)
|
||||
|| var_check_lock(di->di_flags, name, FALSE))
|
||||
return FAIL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if di_flags "flags" indicates variable "name" is read-only.
|
||||
* Also give an error message.
|
||||
|
Reference in New Issue
Block a user