Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve class parser #289

Merged
merged 1 commit into from
May 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions quickjs.c
Original file line number Diff line number Diff line change
@@ -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))
6 changes: 4 additions & 2 deletions tests/test_language.js
Original file line number Diff line number Diff line change
@@ -335,11 +335,13 @@ function test_class()
assert(S.x === 42);
assert(S.y === 42);
assert(S.z === 42);

class P {
get = () => "123"
get = () => "123";
static() { return 42; }
}
assert(new P().get() === "123");
assert(new P().static() === 42);
};

function test_template()