Bug 1233120 - Check token after static in class declaration. r=jwalden

This commit is contained in:
Tooru Fujisawa 2015-12-17 08:15:06 +09:00
parent 09efe1e0a3
commit 1a9d524f0b
2 changed files with 10 additions and 2 deletions

View File

@ -6780,6 +6780,13 @@ Parser<FullParseHandler>::classDefinition(YieldHandling yieldHandling,
if (tt == TOK_NAME && tokenStream.currentName() == context->names().static_) {
if (!tokenStream.peekToken(&tt, TokenStream::KeywordIsName))
return null();
if (tt == TOK_RC) {
tokenStream.consumeKnownToken(tt, TokenStream::KeywordIsName);
report(ParseError, false, null(), JSMSG_UNEXPECTED_TOKEN,
"property name", TokenKindToDesc(tt));
return null();
}
if (tt != TOK_LP) {
if (!checkUnescapedName())
return null();
@ -9249,8 +9256,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, Node propList,
if (!tokenStream.getToken(&ltok, TokenStream::KeywordIsName))
return null();
// TOK_RC should be handled in caller.
MOZ_ASSERT(ltok != TOK_RC);
MOZ_ASSERT(ltok != TOK_RC, "caller should have handled TOK_RC");
bool isGenerator = false;
if (ltok == TOK_MUL) {

View File

@ -479,6 +479,8 @@ function testClasses() {
assertClassError("class NAME { static *y", SyntaxError);
assertClassError("class NAME { static get", SyntaxError);
assertClassError("class NAME { static get y", SyntaxError);
assertClassError("class NAME { static }", SyntaxError);
assertClassError("class NAME { static ;", SyntaxError);
assertClassError("class NAME extends", SyntaxError);
assertClassError("class NAME { constructor() { super", SyntaxError);
assertClassError("class NAME { constructor() { super.", SyntaxError);