diff src/vim9script.c @ 31396:307f68a41b03 v9.0.1031

patch 9.0.1031: Vim9 class is not implemented yet Commit: https://github.com/vim/vim/commit/00b28d6c23d8e662cab27e461825777c0a2e387a Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 8 15:32:33 2022 +0000 patch 9.0.1031: Vim9 class is not implemented yet Problem: Vim9 class is not implemented yet. Solution: Add very basic class support.
author Bram Moolenaar <Bram@vim.org>
date Thu, 08 Dec 2022 16:45:03 +0100
parents 684e6dfa2fba
children 53c3df37a2b0
line wrap: on
line diff
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -838,7 +838,7 @@ vim9_declare_scriptvar(exarg_T *eap, cha
     // parse type, check for reserved name
     p = skipwhite(p + 1);
     type = parse_type(&p, &si->sn_type_list, TRUE);
-    if (type == NULL || check_reserved_name(name) == FAIL)
+    if (type == NULL || check_reserved_name(name, NULL) == FAIL)
     {
 	vim_free(name);
 	return p;
@@ -1126,12 +1126,17 @@ static char *reserved[] = {
 };
 
     int
-check_reserved_name(char_u *name)
+check_reserved_name(char_u *name, cctx_T *cctx)
 {
     int idx;
 
     for (idx = 0; reserved[idx] != NULL; ++idx)
-	if (STRCMP(reserved[idx], name) == 0)
+	if (STRCMP(reserved[idx], name) == 0
+		// "this" can be used in an object method
+		&& !(STRCMP("this", name) == 0
+		    && cctx != NULL
+		    && cctx->ctx_ufunc != NULL
+		    && (cctx->ctx_ufunc->uf_flags & FC_OBJECT)))
 	{
 	    semsg(_(e_cannot_use_reserved_name), name);
 	    return FAIL;