Cherrypick https://github.com/bellard/quickjs/pull/289 (#404)
Co-authored-by: karurochari <nope>
This commit is contained in:
parent
5a7e578482
commit
f588210641
2 changed files with 13 additions and 4 deletions
10
quickjs.c
10
quickjs.c
|
@ -20853,7 +20853,8 @@ static int __exception js_parse_property_name(JSParseState *s,
|
||||||
if (next_token(s))
|
if (next_token(s))
|
||||||
goto fail1;
|
goto fail1;
|
||||||
if (s->token.val == ':' || s->token.val == ',' ||
|
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;
|
is_non_reserved_ident = TRUE;
|
||||||
goto ident_found;
|
goto ident_found;
|
||||||
}
|
}
|
||||||
|
@ -21609,7 +21610,12 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr,
|
||||||
goto fail;
|
goto fail;
|
||||||
continue;
|
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;
|
prop_type = -1;
|
||||||
if (is_static) {
|
if (is_static) {
|
||||||
if (next_token(s))
|
if (next_token(s))
|
||||||
|
|
|
@ -343,10 +343,13 @@ function test_class()
|
||||||
assert(S.x === 42);
|
assert(S.x === 42);
|
||||||
assert(S.y === 42);
|
assert(S.y === 42);
|
||||||
assert(S.z === 42);
|
assert(S.z === 42);
|
||||||
|
|
||||||
class P {
|
class P {
|
||||||
get = () => "123"
|
get = () => "123";
|
||||||
|
static() { return 42; }
|
||||||
}
|
}
|
||||||
assert(new P().get() === "123");
|
assert(new P().get() === "123");
|
||||||
|
assert(new P().static() === 42);
|
||||||
};
|
};
|
||||||
|
|
||||||
function test_template()
|
function test_template()
|
||||||
|
|
Loading…
Reference in a new issue