File tree Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -9631,15 +9631,10 @@ This does NOT work: >
9631
9631
If the system does not support deleting an environment
9632
9632
variable, it is made empty.
9633
9633
9634
- *:cons* *:const* *E996*
9634
+ *:cons* *:const*
9635
9635
:cons[t] {var-name} = {expr1}
9636
9636
:cons[t] [{name1} , {name2} , ...] = {expr1}
9637
- :cons[t] [{name1} , {name2} , ...] .= {expr1}
9638
9637
:cons[t] [{name} , ..., ; {lastname} ] = {expr1}
9639
- :cons[t] {var-name} =<< [trim] {marker}
9640
- text...
9641
- text...
9642
- {marker}
9643
9638
Similar to | :let | , but additionally lock the variable
9644
9639
after setting the value. This is the same as locking
9645
9640
the variable with | :lockvar | just after | :let | , thus: >
@@ -9653,7 +9648,11 @@ text...
9653
9648
| :const | does not allow to for changing a variable. >
9654
9649
:let x = 1
9655
9650
:const x = 2 " Error!
9656
- <
9651
+ < *E996*
9652
+ Note that environment variables, option values and
9653
+ register values cannot be used here, since they cannot
9654
+ be locked.
9655
+
9657
9656
:lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv*
9658
9657
Lock the internal variable {name} . Locking means that
9659
9658
it can no longer be changed (until it is unlocked).
Original file line number Diff line number Diff line change @@ -18,6 +18,19 @@ func Test_define_var_with_lock()
18
18
const b = v: true
19
19
const n = v: null
20
20
21
+ call assert_true (exists (' i' ))
22
+ call assert_true (exists (' f' ))
23
+ call assert_true (exists (' s' ))
24
+ call assert_true (exists (' F' ))
25
+ call assert_true (exists (' l' ))
26
+ call assert_true (exists (' d' ))
27
+ if has (' channel' )
28
+ call assert_true (exists (' j' ))
29
+ call assert_true (exists (' c' ))
30
+ endif
31
+ call assert_true (exists (' b' ))
32
+ call assert_true (exists (' n' ))
33
+
21
34
call assert_fails (' let i = 1' , ' E741:' )
22
35
call assert_fails (' let f = 1.1' , ' E741:' )
23
36
call assert_fails (' let s = "vim"' , ' E741:' )
@@ -199,6 +212,17 @@ func Test_const_with_special_variables()
199
212
call assert_fails (' const &g:encoding = "utf-8"' , ' E996:' )
200
213
endfunc
201
214
215
+ func Test_const_with_eval_name ()
216
+ let s = ' foo'
217
+
218
+ " eval name with :const should work
219
+ const abc_{s } = 1
220
+ const {s }{s } = 1
221
+
222
+ let s2 = ' abc_foo'
223
+ call assert_fails (' const {s2} = "bar"' , ' E995:' )
224
+ endfunc
225
+
202
226
func Test_lock_depth_is_1 ()
203
227
const l = [1 , 2 , 3 ]
204
228
const d = {' foo' : 10 }
Original file line number Diff line number Diff line change @@ -367,7 +367,7 @@ static const int included_patches[] = {
367
367
1557 ,
368
368
1556 ,
369
369
1555 ,
370
- // 1554,
370
+ 1554 ,
371
371
1553 ,
372
372
// 1552,
373
373
// 1551,
You can’t perform that action at this time.
0 commit comments