Bug 1163851 - Actually respect the InHandling parameter in the parser. |pc->parsingForInit| is now unused except for testing; it'll be removed once this has stuck a bit, as this change *does* change semantics in some edge cases. r=efaust

--HG--
extra : rebase_source : 6f145703264eb617f905d9cd4b5884b4430c47fa
This commit is contained in:
Jeff Walden 2015-05-13 21:13:02 -07:00
parent 81f2044adf
commit 4fa5c7ef6a
2 changed files with 34 additions and 9 deletions

View File

@ -6294,12 +6294,6 @@ BinaryOpParseNodeKindToJSOp(ParseNodeKind pnk)
return ParseNodeKindToJSOp[pnk - PNK_BINOP_FIRST];
}
static bool
IsBinaryOpToken(TokenKind tok, bool parsingForInit)
{
return tok == TOK_IN ? !parsingForInit : TokenKindIsBinaryOp(tok);
}
static ParseNodeKind
BinaryOpTokenKindToParseNodeKind(TokenKind tok)
{
@ -6377,10 +6371,8 @@ Parser<ParseHandler>::orExpr1(InHandling inHandling, YieldHandling yieldHandling
if (!tokenStream.getToken(&tok))
return null();
// FIXME: Change this to use |inHandling == InAllowed|, not
// |pc->parsingForInit|.
ParseNodeKind pnk;
if (IsBinaryOpToken(tok, oldParsingForInit)) {
if (tok == TOK_IN ? inHandling == InAllowed : TokenKindIsBinaryOp(tok)) {
pnk = BinaryOpTokenKindToParseNodeKind(tok);
} else {
tok = TOK_EOF;

View File

@ -0,0 +1,33 @@
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/
//-----------------------------------------------------------------------------
var gTestfile = "arrow-function-in-for-statement-head.js";
var BUGNUMBER = 1163851;
var summary =
"|for (x => 0 in 1;;) break;| must be a syntax error per ES6, not an " +
"elaborate nop";
print(BUGNUMBER + ": " + summary);
/**************
* BEGIN TEST *
**************/
try
{
Function("for (x => 0 in 1;;) break;");
throw new Error("didn't throw");
}
catch (e)
{
assertEq(e instanceof SyntaxError, true,
"expected syntax error, got " + e);
}
/******************************************************************************/
if (typeof reportCompare === "function")
reportCompare(true, true);
print("Tests complete");