summaryrefslogtreecommitdiff
path: root/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-04-10 16:01:26 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-04-10 16:01:26 +0200
commit949c105aff1ff0c3edc0a1cb7c713c68509fc156 (patch)
treed9e2a9501a24015318902795b84c7b69e973d7e9 /quickjs.c
parentd546fbfdb7d0f236c30a6c2a1a5641341e9d6aa7 (diff)
downloadquickjs-949c105aff1ff0c3edc0a1cb7c713c68509fc156.tar.gz
quickjs-949c105aff1ff0c3edc0a1cb7c713c68509fc156.zip
fixed class field named get or set
Diffstat (limited to 'quickjs.c')
-rw-r--r--quickjs.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/quickjs.c b/quickjs.c
index 24bb8db..7642d7d 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -22248,15 +22248,20 @@ static int __exception js_parse_property_name(JSParseState *s,
prop_type = PROP_TYPE_IDENT;
if (allow_method) {
- if (token_is_pseudo_keyword(s, JS_ATOM_get)
- || token_is_pseudo_keyword(s, JS_ATOM_set)) {
+ /* if allow_private is true (for class field parsing) and
+ get/set is following by ';' (or LF with ASI), then it
+ is a field name */
+ if ((token_is_pseudo_keyword(s, JS_ATOM_get) ||
+ token_is_pseudo_keyword(s, JS_ATOM_set)) &&
+ (!allow_private || peek_token(s, TRUE) != '\n')) {
/* get x(), set x() */
name = JS_DupAtom(s->ctx, s->token.u.ident.atom);
if (next_token(s))
goto fail1;
if (s->token.val == ':' || s->token.val == ',' ||
s->token.val == '}' || s->token.val == '(' ||
- s->token.val == '=') {
+ s->token.val == '=' ||
+ (s->token.val == ';' && allow_private)) {
is_non_reserved_ident = TRUE;
goto ident_found;
}