diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2025-04-10 16:01:26 +0200 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2025-04-10 16:01:26 +0200 |
commit | 949c105aff1ff0c3edc0a1cb7c713c68509fc156 (patch) | |
tree | d9e2a9501a24015318902795b84c7b69e973d7e9 /quickjs.c | |
parent | d546fbfdb7d0f236c30a6c2a1a5641341e9d6aa7 (diff) | |
download | quickjs-949c105aff1ff0c3edc0a1cb7c713c68509fc156.tar.gz quickjs-949c105aff1ff0c3edc0a1cb7c713c68509fc156.zip |
fixed class field named get or set
Diffstat (limited to 'quickjs.c')
-rw-r--r-- | quickjs.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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; } |