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 #8253)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 995c1d7..2ea487d 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5594,14 +5594,6 @@
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 @@
}
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)