mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibJS: Allow object properties called 'async'
This commit is contained in:
parent
450dedabd1
commit
32016d3924
2 changed files with 10 additions and 1 deletions
|
@ -1486,7 +1486,8 @@ NonnullRefPtr<ObjectExpression> Parser::parse_object_expression()
|
||||||
if (match(TokenType::Async)) {
|
if (match(TokenType::Async)) {
|
||||||
auto lookahead_token = next_token();
|
auto lookahead_token = next_token();
|
||||||
|
|
||||||
if (lookahead_token.type() != TokenType::ParenOpen && !lookahead_token.trivia_contains_line_terminator()) {
|
if (lookahead_token.type() != TokenType::ParenOpen && lookahead_token.type() != TokenType::Colon
|
||||||
|
&& !lookahead_token.trivia_contains_line_terminator()) {
|
||||||
consume(TokenType::Async);
|
consume(TokenType::Async);
|
||||||
function_kind = FunctionKind::Async;
|
function_kind = FunctionKind::Async;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,14 @@ describe("parsing object literal async functions", () => {
|
||||||
expect(`x = { async
|
expect(`x = { async
|
||||||
foo() { } }`).not.toEval();
|
foo() { } }`).not.toEval();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("property on object called async", () => {
|
||||||
|
expect(`x = { async() { } }`).toEval();
|
||||||
|
expect(`x = { async() { await 4; } }`).not.toEval();
|
||||||
|
expect(`x = { async: 3 }`).toEval();
|
||||||
|
expect(`x = { async: await 3, }`).not.toEval();
|
||||||
|
});
|
||||||
|
|
||||||
test("await expression", () => {
|
test("await expression", () => {
|
||||||
expect(`x = { foo() { await bar(); } }`).not.toEval();
|
expect(`x = { foo() { await bar(); } }`).not.toEval();
|
||||||
expect(`x = { foo() { await; } }`).toEval();
|
expect(`x = { foo() { await; } }`).toEval();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue