Bug 1177941 - Do not show warning about unreachable empty statement after return statement. r=Waldo

This commit is contained in:
Tooru Fujisawa 2015-06-30 19:24:28 +09:00
parent 9020fa5cde
commit ee4292f1cc
3 changed files with 8 additions and 5 deletions

View File

@ -702,7 +702,8 @@ class FullParseHandler
bool isStatementPermittedAfterReturnStatement(ParseNode *node) {
ParseNodeKind kind = node->getKind();
return kind == PNK_FUNCTION || kind == PNK_VAR || kind == PNK_BREAK || kind == PNK_THROW;
return kind == PNK_FUNCTION || kind == PNK_VAR || kind == PNK_BREAK || kind == PNK_THROW ||
(kind == PNK_SEMI && !node->pn_kid);
}
inline bool finishInitializerAssignment(ParseNode* pn, ParseNode* init, JSOp op);

View File

@ -45,6 +45,7 @@ class SyntaxParseHandler
NodeHoistableDeclaration,
NodeBreak,
NodeThrow,
NodeEmptyStatement,
NodeSuperProperty,
NodeSuperElement,
@ -294,7 +295,7 @@ class SyntaxParseHandler
Node newStatementList(unsigned blockid, const TokenPos& pos) { return NodeGeneric; }
void addStatementToList(Node list, Node stmt, ParseContext<SyntaxParseHandler>* pc) {}
bool prependInitialYield(Node stmtList, Node gen) { return true; }
Node newEmptyStatement(const TokenPos& pos) { return NodeGeneric; }
Node newEmptyStatement(const TokenPos& pos) { return NodeEmptyStatement; }
Node newExprStatement(Node expr, uint32_t end) {
return expr == NodeUnparenthesizedString ? NodeStringExprStatement : NodeGeneric;
@ -430,7 +431,8 @@ class SyntaxParseHandler
}
bool isStatementPermittedAfterReturnStatement(Node pn) {
return pn == NodeHoistableDeclaration || pn == NodeBreak || pn == NodeThrow;
return pn == NodeHoistableDeclaration || pn == NodeBreak || pn == NodeThrow ||
pn == NodeEmptyStatement;
}
void setOp(Node pn, JSOp op) {}

View File

@ -256,8 +256,8 @@ var f = new Function("return\\n");
// empty statement
testPass(`
function f() {
return
;
return;
; // empty statement
}
`);