From 558f9eb1a350d4857fe2bf8878eca0b37060eb97 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Sun, 5 May 2024 19:54:47 +0200 Subject: Improve class parser (#289) - accept `class P { async = 1 }}` - accept `class P { static = 1 }}` etc. - Fixes #261 --- lib/quickjs/quickjs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c index a71b17a0..3c803906 100644 --- a/lib/quickjs/quickjs.c +++ b/lib/quickjs/quickjs.c @@ -22490,7 +22490,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; } @@ -22506,7 +22506,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; } @@ -23190,7 +23191,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)) -- cgit 1.4.1-2-gfad0