comparison src/testdir/test_const.vim @ 21843:4a4678d26822 v8.2.1471

patch 8.2.1471: :const only locks the variable, not the value Commit: https://github.com/vim/vim/commit/241572794f7e93d2f8b762de2300e5f7e4f07628 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 16 22:50:01 2020 +0200 patch 8.2.1471: :const only locks the variable, not the value Problem: :const only locks the variable, not the value. Solution: Lock the value as ":lockvar 1 var" would do. (closes https://github.com/vim/vim/issues/6719)
author Bram Moolenaar <Bram@vim.org>
date Sun, 16 Aug 2020 23:00:04 +0200
parents da98d2ed8dc5
children fb74a3387694
comparison
equal deleted inserted replaced
21842:f40d7d8ca768 21843:4a4678d26822
39 call assert_fails('let i = 1', 'E741:') 39 call assert_fails('let i = 1', 'E741:')
40 call assert_fails('let f = 1.1', 'E741:') 40 call assert_fails('let f = 1.1', 'E741:')
41 call assert_fails('let s = "vim"', 'E741:') 41 call assert_fails('let s = "vim"', 'E741:')
42 call assert_fails('let F = funcref("s:noop")', 'E741:') 42 call assert_fails('let F = funcref("s:noop")', 'E741:')
43 call assert_fails('let l = [1, 2, 3]', 'E741:') 43 call assert_fails('let l = [1, 2, 3]', 'E741:')
44 call assert_fails('call filter(l, "v:val % 2 == 0")', 'E741:')
44 call assert_fails('let d = {"foo": 10}', 'E741:') 45 call assert_fails('let d = {"foo": 10}', 'E741:')
45 if has('channel') 46 if has('channel')
46 call assert_fails('let j = test_null_job()', 'E741:') 47 call assert_fails('let j = test_null_job()', 'E741:')
47 call assert_fails('let c = test_null_channel()', 'E741:') 48 call assert_fails('let c = test_null_channel()', 'E741:')
48 endif 49 endif
274 275
275 func Test_lock_depth_is_1() 276 func Test_lock_depth_is_1()
276 const l = [1, 2, 3] 277 const l = [1, 2, 3]
277 const d = {'foo': 10} 278 const d = {'foo': 10}
278 279
279 " Modify list 280 " Modify list - setting item is OK, adding/removing items not
280 call add(l, 4)
281 let l[0] = 42 281 let l[0] = 42
282 282 call assert_fails('call add(l, 4)', 'E741:')
283 " Modify dict 283 call assert_fails('unlet l[1]', 'E741:')
284 let d['bar'] = 'hello' 284
285 " Modify dict - changing item is OK, adding/removing items not
286 let d['foo'] = 'hello'
285 let d.foo = 44 287 let d.foo = 44
288 call assert_fails("let d['bar'] = 'hello'", 'E741:')
289 call assert_fails("unlet d['foo']", 'E741:')
286 endfunc 290 endfunc
287 291
288 " vim: shiftwidth=2 sts=2 expandtab 292 " vim: shiftwidth=2 sts=2 expandtab