summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-02-20 22:35:33 +0100
committerBram Moolenaar <Bram@vim.org>2017-02-20 22:35:33 +0100
commite7877fe0de1426f8de9ada825e4f7b64810c7dbc (patch)
tree435e94a70fad5f665ff87c5470f2f4611c0e46c2
parent673911457d6745b6b779eb769c2f41965592d12c (diff)
patch 8.0.0343: b:changedtick can be unlockedv8.0.0343
Problem: b:changedtick can be unlocked, even though it has no effect. (Nikolai Pavlov) Solution: Add a check and error E940. (closes #1496)
-rw-r--r--runtime/doc/eval.txt7
-rw-r--r--src/eval.c6
-rw-r--r--src/testdir/test_changedtick.vim16
-rw-r--r--src/version.c2
4 files changed, 24 insertions, 7 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index bdc4b6388b..30e71345a6 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -9082,9 +9082,12 @@ This does NOT work: >
:lockvar v
:let v = 'asdf' " fails!
:unlet v
-< *E741*
+< *E741* *E940*
If you try to change a locked variable you get an
- error message: "E741: Value is locked: {name}"
+ error message: "E741: Value is locked: {name}".
+ If you try to lock or unlock a built-in variable you
+ get an error message: "E940: Cannot lock or unlock
+ variable {name}".
[depth] is relevant when locking a |List| or
|Dictionary|. It specifies how deep the locking goes:
diff --git a/src/eval.c b/src/eval.c
index 0bb1882414..3cd73b6ea3 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2882,6 +2882,12 @@ do_lock_var(
di = find_var(lp->ll_name, NULL, TRUE);
if (di == NULL)
ret = FAIL;
+ else if ((di->di_flags & DI_FLAGS_FIX)
+ && di->di_tv.v_type != VAR_DICT
+ && di->di_tv.v_type != VAR_LIST)
+ /* For historic reasons this error is not given for a list or dict.
+ * E.g., the b: dict could be locked/unlocked. */
+ EMSG2(_("E940: Cannot lock or unlock variable %s"), lp->ll_name);
else
{
if (lock)
diff --git a/src/testdir/test_changedtick.vim b/src/testdir/test_changedtick.vim
index f273f0f76e..9aaba2770b 100644
--- a/src/testdir/test_changedtick.vim
+++ b/src/testdir/test_changedtick.vim
@@ -33,13 +33,19 @@ func Test_changedtick_bdel()
endfunc
func Test_changedtick_fixed()
- call assert_fails('let b:changedtick = 4', 'E46')
- call assert_fails('let b:["changedtick"] = 4', 'E46')
+ call assert_fails('let b:changedtick = 4', 'E46:')
+ call assert_fails('let b:["changedtick"] = 4', 'E46:')
- call assert_fails('unlet b:changedtick', 'E795')
- call assert_fails('unlet b:["changedtick"]', 'E46')
+ call assert_fails('lockvar b:changedtick', 'E940:')
+ call assert_fails('lockvar b:["changedtick"]', 'E46:')
+ call assert_fails('unlockvar b:changedtick', 'E940:')
+ call assert_fails('unlockvar b:["changedtick"]', 'E46:')
+ call assert_fails('unlet b:changedtick', 'E795:')
+ call assert_fails('unlet b:["changedtick"]', 'E46:')
let d = b:
- call assert_fails('unlet d["changedtick"]', 'E46')
+ call assert_fails('lockvar d["changedtick"]', 'E46:')
+ call assert_fails('unlockvar d["changedtick"]', 'E46:')
+ call assert_fails('unlet d["changedtick"]', 'E46:')
endfunc
diff --git a/src/version.c b/src/version.c
index c1dff6cff7..5db4b111c3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 343,
+/**/
342,
/**/
341,