diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 541df65059..3c38851965 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -3612,55 +3612,6 @@ Parser::pushLetScope(HandleStaticBlockObject blockObj, StmtI return SyntaxParseHandler::NodeFailure; } -/* - * Parse a let block statement. - * In both cases, bindings are not hoisted to the top of the enclosing block - * and thus must be carefully injected between variables() and the let body. - */ -template -typename ParseHandler::Node -Parser::deprecatedLetBlock() -{ - MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_LET)); - - RootedStaticBlockObject blockObj(context, StaticBlockObject::create(context)); - if (!blockObj) - return null(); - - uint32_t begin = pos().begin; - - MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_BEFORE_LET); - - Node vars = variables(PNK_LET, nullptr, blockObj, DontHoistVars); - if (!vars) - return null(); - - MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_LET); - - StmtInfoPC stmtInfo(context); - Node block = pushLetScope(blockObj, &stmtInfo); - if (!block) - return null(); - - MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_LET); - - Node expr = statements(); - if (!expr) - return null(); - MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_LET); - - addTelemetry(JSCompartment::DeprecatedLetBlock); - if (!report(ParseWarning, pc->sc->strict, expr, JSMSG_DEPRECATED_LET_BLOCK)) - return null(); - - handler.setLexicalScopeBody(block, expr); - PopStatementPC(tokenStream, pc); - - TokenPos letPos(begin, pos().end); - - return handler.newLetBlock(vars, block, letPos); -} - template static bool PushBlocklikeStatement(TokenStream& ts, StmtInfoPC* stmt, StmtType type, @@ -4035,45 +3986,6 @@ Parser::lexicalDeclaration(bool) return SyntaxParseHandler::NodeFailure; } -template <> -ParseNode* -Parser::letDeclarationOrBlock() -{ - handler.disableSyntaxParser(); - - /* Check for a let statement. */ - TokenKind tt; - if (!tokenStream.peekToken(&tt)) - return null(); - if (tt == TOK_LP) { - ParseNode* node = deprecatedLetBlock(); - if (!node) - return nullptr; - - MOZ_ASSERT(node->isKind(PNK_LETBLOCK)); - MOZ_ASSERT(node->isArity(PN_BINARY)); - return node; - } - - ParseNode* decl = lexicalDeclaration(/* isConst = */ false); - if (!decl) - return nullptr; - - // let-declarations at global scope are currently treated as plain old var. - // See bug 589199. - MOZ_ASSERT(decl->isKind(PNK_LET) || decl->isKind(PNK_VAR)); - MOZ_ASSERT(decl->isArity(PN_LIST)); - return decl; -} - -template <> -SyntaxParseHandler::Node -Parser::letDeclarationOrBlock() -{ - JS_ALWAYS_FALSE(abortIfSyntaxParser()); - return SyntaxParseHandler::NodeFailure; -} - template typename ParseHandler::Node Parser::importDeclaration() @@ -5733,6 +5645,11 @@ Parser::statement(bool canHaveDirectives) case TOK_LC: return blockStatement(); + case TOK_LET: + if (!abortIfSyntaxParser()) + return null(); + return lexicalDeclaration(/* isConst = */ false); + case TOK_CONST: if (!abortIfSyntaxParser()) return null(); @@ -5751,8 +5668,6 @@ Parser::statement(bool canHaveDirectives) return pn; } - case TOK_LET: - return letDeclarationOrBlock(); case TOK_IMPORT: return importDeclaration(); case TOK_EXPORT: diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index 4723e764fd..825fdc7538 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -548,7 +548,6 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter Node debuggerStatement(); Node lexicalDeclaration(bool isConst); - Node letDeclarationOrBlock(); Node importDeclaration(); Node exportDeclaration(); Node expressionStatement(InvokedPrediction invoked = PredictUninvoked); @@ -605,7 +604,6 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter Node generatorComprehension(uint32_t begin); bool argumentList(Node listNode, bool* isSpread); - Node deprecatedLetBlock(); Node destructuringExpr(BindData* data, TokenKind tt); Node destructuringExprWithoutYield(BindData* data, TokenKind tt, unsigned msg); diff --git a/js/src/js.msg b/js/src/js.msg index 47ed2e45e1..4e64c4c0a5 100644 --- a/js/src/js.msg +++ b/js/src/js.msg @@ -227,7 +227,6 @@ MSG_DEF(JSMSG_CURLY_IN_COMPOUND, 0, JSEXN_SYNTAXERR, "missing } in compoun MSG_DEF(JSMSG_DECLARATION_AFTER_EXPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'export' keyword") MSG_DEF(JSMSG_DECLARATION_AFTER_IMPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'import' keyword") MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated") -MSG_DEF(JSMSG_DEPRECATED_LET_BLOCK, 0, JSEXN_NONE, "JavaScript 1.7's let blocks are deprecated") MSG_DEF(JSMSG_DEPRECATED_FOR_EACH, 0, JSEXN_NONE, "JavaScript 1.6's for-each-in loops are deprecated; consider using ES6 for-of instead") MSG_DEF(JSMSG_DEPRECATED_OCTAL, 0, JSEXN_SYNTAXERR, "octal literals and octal escape sequences are deprecated") MSG_DEF(JSMSG_DEPRECATED_PRAGMA, 1, JSEXN_NONE, "Using //@ to indicate {0} pragmas is deprecated. Use //# instead") diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h index 8db07d3855..d0dd54f40c 100644 --- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -29,11 +29,11 @@ namespace js { * * https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode */ -static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 248; +static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 249; static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND); -static_assert(JSErr_Limit == 368, +static_assert(JSErr_Limit == 367, "GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or " "removed MSG_DEFs from js.msg, you should increment " "XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "