about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-05-05 19:54:47 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-07 13:13:02 +0200
commit558f9eb1a350d4857fe2bf8878eca0b37060eb97 (patch)
tree0f02434f4e759c21b20b2cfb379cc53b35e34d7b /lib
parent7d587def6e7e8243cd27062fbaaf062f3b2f53c3 (diff)
downloadchawan-558f9eb1a350d4857fe2bf8878eca0b37060eb97.tar.gz
Improve class parser (#289)
- accept `class P { async = 1 }}`
- accept `class P { static = 1 }}` etc.
- Fixes #261
Diffstat (limited to 'lib')
-rw-r--r--lib/quickjs/quickjs.c12
1 files changed, 9 insertions, 3 deletions
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))