diff src/vim9compile.c @ 23497:2247a2ce3630 v8.2.2291

patch 8.2.2291: Vim9: cannot use "null" for v:null Commit: https://github.com/vim/vim/commit/67977821270bd328cd37c4ace38fb97f21ad4fd5 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 3 21:53:53 2021 +0100 patch 8.2.2291: Vim9: cannot use "null" for v:null Problem: Vim9: cannot use "null" for v:null. Solution: Support "null" like "true" and "false". (closes https://github.com/vim/vim/issues/7495)
author Bram Moolenaar <Bram@vim.org>
date Sun, 03 Jan 2021 22:00:04 +0100
parents 1f85acfb23cd
children bb29b09902d5
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3968,6 +3968,20 @@ compile_expr7(
 		    break;
 
 	/*
+	 * "null" constant
+	 */
+	case 'n':   if (STRNCMP(*arg, "null", 4) == 0
+						   && !eval_isnamec((*arg)[5]))
+		    {
+			*arg += 4;
+			rettv->v_type = VAR_SPECIAL;
+			rettv->vval.v_number = VVAL_NULL;
+		    }
+		    else
+			ret = NOTDONE;
+		    break;
+
+	/*
 	 * List: [expr, expr]
 	 */
 	case '[':   ret = compile_list(arg, cctx, ppconst);
@@ -5006,6 +5020,7 @@ assignment_len(char_u *p, int *heredoc)
 static char *reserved[] = {
     "true",
     "false",
+    "null",
     NULL
 };