summaryrefslogtreecommitdiff
path: root/quickjs.c
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-05-05 19:54:47 +0200
committerGitHub <noreply@github.com>2024-05-05 19:54:47 +0200
commit0c8fecab2392387d76a46e556b5b8e5989b4b1c1 (patch)
treef11bae7c9dbeddaac9f3c4f472863406fc6144ef /quickjs.c
parentd9c699f528755360e32f7d2755ad3f91b575b4f9 (diff)
downloadquickjs-0c8fecab2392387d76a46e556b5b8e5989b4b1c1.tar.gz
quickjs-0c8fecab2392387d76a46e556b5b8e5989b4b1c1.zip
Improve class parser (#289)
- accept `class P { async = 1 }}` - accept `class P { static = 1 }}` etc. - Fixes #261
Diffstat (limited to 'quickjs.c')
-rw-r--r--quickjs.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/quickjs.c b/quickjs.c
index 798d509..3c1c326 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -22381,7 +22381,7 @@ static int __exception js_parse_property_name(JSParseState *s,
goto fail1;
if (s->token.val == ':' || s->token.val == ',' ||
s->token.val == '}' || s->token.val == '(' ||
- s->token.val == '=' ) {
+ s->token.val == '=') {
is_non_reserved_ident = TRUE;
goto ident_found;
}
@@ -22397,7 +22397,8 @@ static int __exception js_parse_property_name(JSParseState *s,
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 == '=') {
is_non_reserved_ident = TRUE;
goto ident_found;
}
@@ -23081,7 +23082,12 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr,
goto fail;
continue;
}
- is_static = (s->token.val == TOK_STATIC);
+ is_static = FALSE;
+ if (s->token.val == TOK_STATIC) {
+ int next = peek_token(s, TRUE);
+ if (!(next == ';' || next == '}' || next == '(' || next == '='))
+ is_static = TRUE;
+ }
prop_type = -1;
if (is_static) {
if (next_token(s))