Permalink
Browse files

patch 8.0.0345: islocked('d.changedtick') does not work

Problem:    islocked('d.changedtick') does not work.
Solution:   Make it work.
  • Loading branch information...
brammool committed Feb 21, 2017
1 parent 49439c4 commit 3a257737726ba42980bf38ec9a0c80944756af24
Showing with 15 additions and 3 deletions.
  1. +1 −1 src/buffer.c
  2. +3 −1 src/eval.c
  3. +1 −1 src/evalfunc.c
  4. +6 −0 src/testdir/test_changedtick.vim
  5. +2 −0 src/version.c
  6. +2 −0 src/vim.h
View
@@ -884,7 +884,7 @@ init_changedtick(buf_T *buf)
if (di != NULL)
{
- di->di_flags |= DI_FLAGS_LOCK | DI_FLAGS_FIX | DI_FLAGS_RO;
+ di->di_flags |= DI_FLAGS_FIX | DI_FLAGS_RO;
di->di_tv.v_type = VAR_NUMBER;
di->di_tv.v_lock = VAR_FIXED;
di->di_tv.vval.v_number = 0;
View
@@ -1811,6 +1811,7 @@ ex_let_one(
*
* flags:
* GLV_QUIET: do not give error messages
+ * GLV_READ_ONLY: will not change the variable
* GLV_NO_AUTOLOAD: do not use script autoloading
*
* Returns a pointer to just after the name, including indexes.
@@ -2078,7 +2079,8 @@ get_lval(
break;
}
/* existing variable, need to check if it can be changed */
- else if (var_check_ro(lp->ll_di->di_flags, name, FALSE))
+ else if ((flags & GLV_READ_ONLY) == 0
+ && var_check_ro(lp->ll_di->di_flags, name, FALSE))
{
clear_tv(&var1);
return NULL;
View
@@ -6561,7 +6561,7 @@ f_islocked(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = -1;
end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE,
- GLV_NO_AUTOLOAD, FNE_CHECK_START);
+ GLV_NO_AUTOLOAD | GLV_READ_ONLY, FNE_CHECK_START);
if (end != NULL && lv.ll_name != NULL)
{
if (*end != NUL)
@@ -32,6 +32,12 @@ func Test_changedtick_bdel()
call assert_equal(v + 1, getbufvar(bnr, 'changedtick'))
endfunc
+func Test_changedtick_islocked()
+ call assert_equal(0, islocked('b:changedtick'))
+ let d = b:
+ call assert_equal(0, islocked('d.changedtick'))
+endfunc
+
func Test_changedtick_fixed()
call assert_fails('let b:changedtick = 4', 'E46:')
call assert_fails('let b:["changedtick"] = 4', 'E46:')
View
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 345,
/**/
344,
/**/
View
@@ -2474,10 +2474,12 @@ typedef enum {
#define TFN_QUIET 2 /* no error messages */
#define TFN_NO_AUTOLOAD 4 /* do not use script autoloading */
#define TFN_NO_DEREF 8 /* do not dereference a Funcref */
+#define TFN_READ_ONLY 16 /* will not change the var */
/* Values for get_lval() flags argument: */
#define GLV_QUIET TFN_QUIET /* no error messages */
#define GLV_NO_AUTOLOAD TFN_NO_AUTOLOAD /* do not use script autoloading */
+#define GLV_READ_ONLY TFN_READ_ONLY /* will not change the var */
#define DO_NOT_FREE_CNT 99999 /* refcount for dict or list that should not
be freed. */

0 comments on commit 3a25773

Please sign in to comment.