Patch 8.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)
Files:      src/eval.c, src/testdir/test_changedtick.vim, runtime/doc/eval.txt


*** ../vim-8.0.0342/src/eval.c  2017-02-17 16:31:16.917294167 +0100
--- src/eval.c  2017-02-20 22:31:32.023285476 +0100
***************
*** 2882,2887 ****
--- 2882,2893 ----
        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)
*** ../vim-8.0.0342/src/testdir/test_changedtick.vim    2017-02-17 
16:31:16.929294079 +0100
--- src/testdir/test_changedtick.vim    2017-02-20 22:20:30.172487079 +0100
***************
*** 33,45 ****
  endfunc
  
  func Test_changedtick_fixed()
!   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')
  
    let d = b:
!   call assert_fails('unlet d["changedtick"]', 'E46')
  
  endfunc
--- 33,51 ----
  endfunc
  
  func Test_changedtick_fixed()
!   call assert_fails('let b:changedtick = 4', 'E46:')
!   call assert_fails('let b:["changedtick"] = 4', '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('lockvar d["changedtick"]', 'E46:')
!   call assert_fails('unlockvar d["changedtick"]', 'E46:')
!   call assert_fails('unlet d["changedtick"]', 'E46:')
  
  endfunc
*** ../vim-8.0.0342/runtime/doc/eval.txt        2017-02-01 17:24:29.677328148 
+0100
--- runtime/doc/eval.txt        2017-02-20 22:15:56.938641719 +0100
***************
*** 9063,9071 ****
                                :lockvar v
                                :let v = 'asdf'         " fails!
                                :unlet v
! <                                                     *E741*
                        If you try to change a locked variable you get an
!                       error message: "E741: Value is locked: {name}"
  
                        [depth] is relevant when locking a |List| or
                        |Dictionary|.  It specifies how deep the locking goes:
--- 9082,9093 ----
                                :lockvar v
                                :let v = 'asdf'         " fails!
                                :unlet v
! <                                                     *E741* *E940*
                        If you try to change a locked variable you get an
!                       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:
*** ../vim-8.0.0342/src/version.c       2017-02-19 21:07:01.006386644 +0100
--- src/version.c       2017-02-20 22:22:02.543759670 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     343,
  /**/

-- 
For society, it's probably a good thing that engineers value function over
appearance.  For example, you wouldn't want engineers to build nuclear power
plants that only _look_ like they would keep all the radiation inside.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui