mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 09:07:30 +09:00
Issue #1918 - m-c 1358246: Report syntax error for stray "async" keyword in object literal property name.
This commit is contained in:
parent
5dc15ae641
commit
5e1b813aac
2 changed files with 39 additions and 18 deletions
|
|
@ -9771,6 +9771,21 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
|||
return null();
|
||||
break;
|
||||
|
||||
case TOK_STRING: {
|
||||
propAtom.set(tokenStream.currentToken().atom());
|
||||
uint32_t index;
|
||||
if (propAtom->isIndex(&index)) {
|
||||
propName = handler.newNumber(index, NoDecimal, pos());
|
||||
if (!propName)
|
||||
return null();
|
||||
break;
|
||||
}
|
||||
propName = stringLiteral();
|
||||
if (!propName)
|
||||
return null();
|
||||
break;
|
||||
}
|
||||
|
||||
case TOK_LB:
|
||||
propName = computedPropertyName(yieldHandling, maybeDecl, propList);
|
||||
if (!propName)
|
||||
|
|
@ -9784,7 +9799,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
|||
}
|
||||
|
||||
propAtom.set(tokenStream.currentName());
|
||||
// Do not look for accessor syntax on generators
|
||||
// Do not look for accessor syntax on generator or async methods.
|
||||
if (isGenerator || isAsync || !(ltok == TOK_GET || ltok == TOK_SET)) {
|
||||
propName = handler.newObjectLiteralPropertyName(propAtom, pos());
|
||||
if (!propName)
|
||||
|
|
@ -9839,21 +9854,6 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
|||
return null();
|
||||
break;
|
||||
}
|
||||
|
||||
case TOK_STRING: {
|
||||
propAtom.set(tokenStream.currentToken().atom());
|
||||
uint32_t index;
|
||||
if (propAtom->isIndex(&index)) {
|
||||
propName = handler.newNumber(index, NoDecimal, pos());
|
||||
if (!propName)
|
||||
return null();
|
||||
break;
|
||||
}
|
||||
propName = stringLiteral();
|
||||
if (!propName)
|
||||
return null();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TokenKind tt;
|
||||
|
|
@ -9861,7 +9861,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
|||
return null();
|
||||
|
||||
if (tt == TOK_COLON) {
|
||||
if (isGenerator) {
|
||||
if (isGenerator || isAsync) {
|
||||
error(JSMSG_BAD_PROP_ID);
|
||||
return null();
|
||||
}
|
||||
|
|
@ -9872,7 +9872,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
|||
if (TokenKindIsPossibleIdentifierName(ltok) &&
|
||||
(tt == TOK_COMMA || tt == TOK_RC || tt == TOK_ASSIGN))
|
||||
{
|
||||
if (isGenerator) {
|
||||
if (isGenerator || isAsync) {
|
||||
error(JSMSG_BAD_PROP_ID);
|
||||
return null();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
function assertSyntaxError(code) {
|
||||
assertThrowsInstanceOf(() => { Function(code); }, SyntaxError, "Function:" + code);
|
||||
assertThrowsInstanceOf(() => { eval(code); }, SyntaxError, "eval:" + code);
|
||||
var ieval = eval;
|
||||
assertThrowsInstanceOf(() => { ieval(code); }, SyntaxError, "indirect eval:" + code);
|
||||
}
|
||||
|
||||
assertSyntaxError(`({async async: 0})`);
|
||||
assertSyntaxError(`({async async})`);
|
||||
assertSyntaxError(`({async async, })`);
|
||||
assertSyntaxError(`({async async = 0} = {})`);
|
||||
|
||||
for (let decl of ["var", "let", "const"]) {
|
||||
assertSyntaxError(`${decl} {async async: a} = {}`);
|
||||
assertSyntaxError(`${decl} {async async} = {}`);
|
||||
assertSyntaxError(`${decl} {async async, } = {}`);
|
||||
assertSyntaxError(`${decl} {async async = 0} = {}`);
|
||||
}
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
Loading…
Add table
Add a link
Reference in a new issue