Mercurial > vim
comparison src/vim9script.c @ 32475:a44d7e4ac1c0 v9.0.1569
patch 9.0.1569: cannot use "this.member" in lambda in class method
Commit: https://github.com/vim/vim/commit/2bd6a09691fc71974ca7ab5973f8e08fdd2a889a
Author: h-east <h.east.727@gmail.com>
Date: Fri May 19 19:01:17 2023 +0100
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 19 May 2023 20:15:04 +0200 |
parents | 04d9dff67d99 |
children | 304341915488 |
comparison
equal
deleted
inserted
replaced
32474:a715c20f474f | 32475:a44d7e4ac1c0 |
---|---|
836 name = vim_strnsave(arg, p - arg); | 836 name = vim_strnsave(arg, p - arg); |
837 | 837 |
838 // parse type, check for reserved name | 838 // parse type, check for reserved name |
839 p = skipwhite(p + 1); | 839 p = skipwhite(p + 1); |
840 type = parse_type(&p, &si->sn_type_list, TRUE); | 840 type = parse_type(&p, &si->sn_type_list, TRUE); |
841 if (type == NULL || check_reserved_name(name, NULL) == FAIL) | 841 if (type == NULL || check_reserved_name(name, FALSE) == FAIL) |
842 { | 842 { |
843 vim_free(name); | 843 vim_free(name); |
844 return p; | 844 return p; |
845 } | 845 } |
846 | 846 |
1125 "this", | 1125 "this", |
1126 NULL | 1126 NULL |
1127 }; | 1127 }; |
1128 | 1128 |
1129 int | 1129 int |
1130 check_reserved_name(char_u *name, cctx_T *cctx) | 1130 check_reserved_name(char_u *name, int is_objm_access) |
1131 { | 1131 { |
1132 int idx; | 1132 int idx; |
1133 | 1133 |
1134 for (idx = 0; reserved[idx] != NULL; ++idx) | 1134 for (idx = 0; reserved[idx] != NULL; ++idx) |
1135 if (STRCMP(reserved[idx], name) == 0 | 1135 if (STRCMP(reserved[idx], name) == 0 |
1136 // "this" can be used in an object method | 1136 && !(STRCMP("this", name) == 0 && is_objm_access)) |
1137 && !(STRCMP("this", name) == 0 | |
1138 && cctx != NULL | |
1139 && cctx->ctx_ufunc != NULL | |
1140 && (cctx->ctx_ufunc->uf_flags & (FC_OBJECT|FC_NEW)))) | |
1141 { | 1137 { |
1142 semsg(_(e_cannot_use_reserved_name_str), name); | 1138 semsg(_(e_cannot_use_reserved_name_str), name); |
1143 return FAIL; | 1139 return FAIL; |
1144 } | 1140 } |
1145 return OK; | 1141 return OK; |