mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-28 01:57: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();
|
return null();
|
||||||
break;
|
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:
|
case TOK_LB:
|
||||||
propName = computedPropertyName(yieldHandling, maybeDecl, propList);
|
propName = computedPropertyName(yieldHandling, maybeDecl, propList);
|
||||||
if (!propName)
|
if (!propName)
|
||||||
|
|
@ -9784,7 +9799,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
||||||
}
|
}
|
||||||
|
|
||||||
propAtom.set(tokenStream.currentName());
|
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)) {
|
if (isGenerator || isAsync || !(ltok == TOK_GET || ltok == TOK_SET)) {
|
||||||
propName = handler.newObjectLiteralPropertyName(propAtom, pos());
|
propName = handler.newObjectLiteralPropertyName(propAtom, pos());
|
||||||
if (!propName)
|
if (!propName)
|
||||||
|
|
@ -9839,21 +9854,6 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
||||||
return null();
|
return null();
|
||||||
break;
|
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;
|
TokenKind tt;
|
||||||
|
|
@ -9861,7 +9861,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
||||||
return null();
|
return null();
|
||||||
|
|
||||||
if (tt == TOK_COLON) {
|
if (tt == TOK_COLON) {
|
||||||
if (isGenerator) {
|
if (isGenerator || isAsync) {
|
||||||
error(JSMSG_BAD_PROP_ID);
|
error(JSMSG_BAD_PROP_ID);
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
|
|
@ -9872,7 +9872,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
|
||||||
if (TokenKindIsPossibleIdentifierName(ltok) &&
|
if (TokenKindIsPossibleIdentifierName(ltok) &&
|
||||||
(tt == TOK_COMMA || tt == TOK_RC || tt == TOK_ASSIGN))
|
(tt == TOK_COMMA || tt == TOK_RC || tt == TOK_ASSIGN))
|
||||||
{
|
{
|
||||||
if (isGenerator) {
|
if (isGenerator || isAsync) {
|
||||||
error(JSMSG_BAD_PROP_ID);
|
error(JSMSG_BAD_PROP_ID);
|
||||||
return null();
|
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