diff src/vim9compile.c @ 24717:bf8feac8a89a v8.2.2897

patch 8.2.2897: Vim9: can use reserved words at the script level Commit: https://github.com/vim/vim/commit/d0edaf9dc253e619ccc321ceaac321aee11c1ea5 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 28 21:06:08 2021 +0200 patch 8.2.2897: Vim9: can use reserved words at the script level Problem: Vim9: can use reserved words at the script level. Solution: Check variable names for reserved words. (closes https://github.com/vim/vim/issues/8253)
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 May 2021 21:15:03 +0200
parents 34a5329b85aa
children 7464d4c927f5
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5594,14 +5594,6 @@ assignment_len(char_u *p, int *heredoc)
     return 0;
 }
 
-// words that cannot be used as a variable
-static char *reserved[] = {
-    "true",
-    "false",
-    "null",
-    NULL
-};
-
 /*
  * Generate the load instruction for "name".
  */
@@ -5995,16 +5987,9 @@ compile_lhs(
 	}
 	else
 	{
-	    int	    idx;
-
 	    // No specific kind of variable recognized, just a name.
-	    for (idx = 0; reserved[idx] != NULL; ++idx)
-		if (STRCMP(reserved[idx], lhs->lhs_name) == 0)
-		{
-		    semsg(_(e_cannot_use_reserved_name), lhs->lhs_name);
-		    return FAIL;
-		}
-
+	    if (check_reserved_name(lhs->lhs_name) == FAIL)
+		return FAIL;
 
 	    if (lookup_local(var_start, lhs->lhs_varlen,
 					     &lhs->lhs_local_lvar, cctx) == OK)