0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.0.1569: cannot use "this.member" in lambda in class method

Problem:    Cannot use "this.member" in lambda in class method.
Solution:   Adjust check for reserved keyword. (Hirohito Higashi,
            closes #12416, closes #12076, closes #12336)
This commit is contained in:
h-east
2023-05-19 19:01:17 +01:00
committed by Bram Moolenaar
parent d49f646bf5
commit 2bd6a09691
6 changed files with 30 additions and 10 deletions

View File

@@ -838,7 +838,7 @@ vim9_declare_scriptvar(exarg_T *eap, char_u *arg)
// 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, NULL) == FAIL)
if (type == NULL || check_reserved_name(name, FALSE) == FAIL)
{
vim_free(name);
return p;
@@ -1127,17 +1127,13 @@ static char *reserved[] = {
};
int
check_reserved_name(char_u *name, cctx_T *cctx)
check_reserved_name(char_u *name, int is_objm_access)
{
int idx;
for (idx = 0; reserved[idx] != NULL; ++idx)
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|FC_NEW))))
&& !(STRCMP("this", name) == 0 && is_objm_access))
{
semsg(_(e_cannot_use_reserved_name_str), name);
return FAIL;