We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ef951d commit 6797782Copy full SHA for 6797782
5 files changed
runtime/doc/vim9.txt
@@ -1,4 +1,4 @@
1
-*vim9.txt* For Vim version 8.2. Last change: 2021 Jan 02
+*vim9.txt* For Vim version 8.2. Last change: 2021 Jan 03
2
3
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -640,11 +640,11 @@ always converted to string: >
640
641
Simple types are string, float, special and bool. For other types |string()|
642
can be used.
643
- *false* *true*
644
-In Vim9 script one can use "true" for v:true and "false" for v:false. When
645
-converting a boolean to a string "false" and "true" are used, not "v:false"
646
-and "v:true" like in legacy script. "v:none" and "v:null" are not changed,
647
-they are only used in JSON.
+ *false* *true* *null*
+In Vim9 script one can use "true" for v:true, "false" for v:false and "null"
+for v:null. When converting a boolean to a string "false" and "true" are
+used, not "v:false" and "v:true" like in legacy script. "v:none" is not
+changed, it is only used in JSON and has no equivalent in other languages.
648
649
Indexing a string with [idx] or [idx, idx] uses character indexes instead of
650
byte indexes. Example: >
src/evalvars.c
@@ -2072,8 +2072,8 @@ get_var_special_name(int nr)
2072
{
2073
case VVAL_FALSE: return in_vim9script() ? "false" : "v:false";
2074
case VVAL_TRUE: return in_vim9script() ? "true" : "v:true";
2075
+ case VVAL_NULL: return in_vim9script() ? "null" : "v:null";
2076
case VVAL_NONE: return "v:none";
- case VVAL_NULL: return "v:null";
2077
}
2078
internal_error("get_var_special_name()");
2079
return "42";
src/testdir/test_vim9_expr.vim
@@ -511,6 +511,8 @@ def Test_expr4_equal()
511
assert_equal(true, v:none == v:none)
512
assert_equal(false, v:none == v:null)
513
assert_equal(true, g:anone == v:none)
514
+ assert_equal(true, null == v:null)
515
+ assert_equal(true, null == g:anull)
516
assert_equal(false, v:none == g:anull)
517
518
var nr0 = 0
@@ -1063,7 +1065,7 @@ def Test_expr5()
1063
1065
1064
1066
assert_equal('atrue', 'a' .. true)
1067
assert_equal('afalse', 'a' .. false)
- assert_equal('av:null', 'a' .. v:null)
1068
+ assert_equal('anull', 'a' .. v:null)
1069
assert_equal('av:none', 'a' .. v:none)
1070
if has('float')
1071
assert_equal('a0.123', 'a' .. 0.123)
@@ -1657,6 +1659,7 @@ def Test_expr7_special()
1657
1659
assert_equal(false, f)
1658
1660
1661
assert_equal(g:special_null, v:null)
1662
+ assert_equal(g:special_null, null)
1663
assert_equal(g:special_none, v:none)
1664
END
1665
CheckDefAndScriptSuccess(lines)
src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
750
751
static int included_patches[] =
752
{ /* Add new patch number below this line */
753
+/**/
754
+ 2291,
755
/**/
756
2290,
757
src/vim9compile.c
@@ -3967,6 +3967,20 @@ compile_expr7(
3967
ret = NOTDONE;
3968
break;
3969
3970
+ /*
3971
+ * "null" constant
3972
+ */
3973
+ case 'n': if (STRNCMP(*arg, "null", 4) == 0
3974
+ && !eval_isnamec((*arg)[5]))
3975
+ {
3976
+ *arg += 4;
3977
+ rettv->v_type = VAR_SPECIAL;
3978
+ rettv->vval.v_number = VVAL_NULL;
3979
+ }
3980
+ else
3981
+ ret = NOTDONE;
3982
+ break;
3983
+
3984
/*
3985
* List: [expr, expr]
3986
*/
@@ -5006,6 +5020,7 @@ assignment_len(char_u *p, int *heredoc)
5006
5020
static char *reserved[] = {
5007
5021
"true",
5008
5022
"false",
5023
+ "null",
5009
5024
NULL
5010
5025
};
5011
5026
0 commit comments