Fix invalid exception for class method with name "get"
Ref: https://github.com/bellard/quickjs/pull/258
This commit is contained in:
parent
5ca3c509d0
commit
99c6719b7d
2 changed files with 9 additions and 3 deletions
|
@ -20810,7 +20810,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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,6 +336,10 @@ 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 {
|
||||||
|
get = () => "123"
|
||||||
|
}
|
||||||
|
assert(new P().get() === "123");
|
||||||
};
|
};
|
||||||
|
|
||||||
function test_template()
|
function test_template()
|
||||||
|
@ -363,8 +367,9 @@ function test_template_skip()
|
||||||
function test_object_literal()
|
function test_object_literal()
|
||||||
{
|
{
|
||||||
var x = 0, get = 1, set = 2; async = 3;
|
var x = 0, get = 1, set = 2; async = 3;
|
||||||
a = { get: 2, set: 3, async: 4 };
|
a = { get: 2, set: 3, async: 4, get a(){ return this.get} };
|
||||||
assert(JSON.stringify(a), '{"get":2,"set":3,"async":4}');
|
assert(JSON.stringify(a), '{"get":2,"set":3,"async":4,"a":2}');
|
||||||
|
assert(a.a === 2);
|
||||||
|
|
||||||
a = { x, get, set, async };
|
a = { x, get, set, async };
|
||||||
assert(JSON.stringify(a), '{"x":0,"get":1,"set":2,"async":3}');
|
assert(JSON.stringify(a), '{"x":0,"get":1,"set":2,"async":3}');
|
||||||
|
|
Loading…
Reference in a new issue