@@ -786,9 +786,6 @@ Parser::Parser(ParseInfo* info)
786786 set_allow_natives (FLAG_allow_natives_syntax || info->is_native ());
787787 set_allow_tailcalls (FLAG_harmony_tailcalls && !info->is_native () &&
788788 info->isolate ()->is_tail_call_elimination_enabled ());
789- set_allow_harmony_sloppy (FLAG_harmony_sloppy);
790- set_allow_harmony_sloppy_function (FLAG_harmony_sloppy_function);
791- set_allow_harmony_sloppy_let (FLAG_harmony_sloppy_let);
792789 set_allow_harmony_do_expressions (FLAG_harmony_do_expressions);
793790 set_allow_harmony_function_name (FLAG_harmony_function_name);
794791 set_allow_harmony_function_sent (FLAG_harmony_function_sent);
@@ -941,7 +938,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
941938 if (ok && is_strict (language_mode ())) {
942939 CheckStrictOctalLiteral (beg_pos, scanner ()->location ().end_pos , &ok);
943940 }
944- if (ok && is_sloppy (language_mode ()) && allow_harmony_sloppy_function () ) {
941+ if (ok && is_sloppy (language_mode ())) {
945942 // TODO(littledan): Function bindings on the global object that modify
946943 // pre-existing bindings should be made writable, enumerable and
947944 // nonconfigurable if possible, whereas this code will leave attributes
@@ -1258,10 +1255,7 @@ Statement* Parser::ParseStatementListItem(bool* ok) {
12581255 Consume (Token::CLASS);
12591256 return ParseClassDeclaration (NULL , ok);
12601257 case Token::CONST:
1261- if (allow_const ()) {
1262- return ParseVariableStatement (kStatementListItem , NULL , ok);
1263- }
1264- break ;
1258+ return ParseVariableStatement (kStatementListItem , NULL , ok);
12651259 case Token::VAR:
12661260 return ParseVariableStatement (kStatementListItem , NULL , ok);
12671261 case Token::LET:
@@ -1909,11 +1903,8 @@ Variable* Parser::Declare(Declaration* declaration,
19091903 }
19101904 var = declaration_scope->DeclareLocal (
19111905 name, mode, declaration->initialization (), kind, kNotAssigned );
1912- } else if ((IsLexicalVariableMode (mode) ||
1913- IsLexicalVariableMode (var->mode ())) &&
1914- // Lexical bindings may appear for some parameters in sloppy
1915- // mode even with --harmony-sloppy off.
1916- (is_strict (language_mode ()) || allow_harmony_sloppy ())) {
1906+ } else if (IsLexicalVariableMode (mode) ||
1907+ IsLexicalVariableMode (var->mode ())) {
19171908 // Allow duplicate function decls for web compat, see bug 4693.
19181909 if (is_sloppy (language_mode ()) && is_function_declaration &&
19191910 var->is_function ()) {
@@ -2103,19 +2094,14 @@ Statement* Parser::ParseFunctionDeclaration(
21032094 // initial value upon entering the corresponding scope.
21042095 // In ES6, a function behaves as a lexical binding, except in
21052096 // a script scope, or the initial scope of eval or another function.
2106- VariableMode mode =
2107- (is_strict (language_mode ()) || allow_harmony_sloppy_function ()) &&
2108- !scope_->is_declaration_scope ()
2109- ? LET
2110- : VAR;
2097+ VariableMode mode = !scope_->is_declaration_scope () ? LET : VAR;
21112098 VariableProxy* proxy = NewUnresolved (name, mode);
21122099 Declaration* declaration =
21132100 factory ()->NewFunctionDeclaration (proxy, mode, fun, scope_, pos);
21142101 Declare (declaration, DeclarationDescriptor::NORMAL, true , CHECK_OK);
21152102 if (names) names->Add (name, zone ());
21162103 EmptyStatement* empty = factory ()->NewEmptyStatement (RelocInfo::kNoPosition );
2117- if (is_sloppy (language_mode ()) && allow_harmony_sloppy_function () &&
2118- !scope_->is_declaration_scope ()) {
2104+ if (is_sloppy (language_mode ()) && !scope_->is_declaration_scope ()) {
21192105 SloppyBlockFunctionStatement* delegate =
21202106 factory ()->NewSloppyBlockFunctionStatement (empty, scope_);
21212107 scope_->DeclarationScope ()->sloppy_block_function_map ()->Declare (name,
@@ -2143,12 +2129,6 @@ Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names,
21432129 //
21442130 // so rewrite it as such.
21452131
2146- if (!allow_harmony_sloppy () && is_sloppy (language_mode ())) {
2147- ReportMessage (MessageTemplate::kSloppyLexical );
2148- *ok = false ;
2149- return NULL ;
2150- }
2151-
21522132 int pos = position ();
21532133 bool is_strict_reserved = false ;
21542134 const AstRawString* name =
@@ -2279,12 +2259,11 @@ Block* Parser::ParseVariableDeclarations(
22792259
22802260 if (peek () == Token::VAR) {
22812261 Consume (Token::VAR);
2282- } else if (peek () == Token::CONST && allow_const () ) {
2262+ } else if (peek () == Token::CONST) {
22832263 Consume (Token::CONST);
2284- DCHECK (is_strict (language_mode ()) || allow_harmony_sloppy ());
22852264 DCHECK (var_context != kStatement );
22862265 parsing_result->descriptor .mode = CONST;
2287- } else if (peek () == Token::LET && allow_let () ) {
2266+ } else if (peek () == Token::LET) {
22882267 Consume (Token::LET);
22892268 DCHECK (var_context != kStatement );
22902269 parsing_result->descriptor .mode = LET;
@@ -2493,15 +2472,6 @@ Statement* Parser::ParseExpressionOrLabelledStatement(
24932472 }
24942473
24952474 // Parsed expression statement, followed by semicolon.
2496- // Detect attempts at 'let' declarations in sloppy mode.
2497- if (!allow_harmony_sloppy_let () && peek () == Token::IDENTIFIER &&
2498- expr->AsVariableProxy () != NULL &&
2499- expr->AsVariableProxy ()->raw_name () ==
2500- ast_value_factory ()->let_string ()) {
2501- ReportMessage (MessageTemplate::kSloppyLexical , NULL );
2502- *ok = false ;
2503- return NULL ;
2504- }
25052475 ExpectSemicolon (CHECK_OK);
25062476 return factory ()->NewExpressionStatement (expr, pos);
25072477}
@@ -3497,10 +3467,9 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
34973467 Expect (Token::FOR, CHECK_OK);
34983468 Expect (Token::LPAREN, CHECK_OK);
34993469 for_scope->set_start_position (scanner ()->location ().beg_pos );
3500- bool is_let_identifier_expression = false ;
35013470 DeclarationParsingResult parsing_result;
35023471 if (peek () != Token::SEMICOLON) {
3503- if (peek () == Token::VAR || ( peek () == Token::CONST && allow_const ()) ||
3472+ if (peek () == Token::VAR || peek () == Token::CONST ||
35043473 (peek () == Token::LET && IsNextLetKeyword ())) {
35053474 ParseVariableDeclarations (kForStatement , &parsing_result, nullptr ,
35063475 CHECK_OK);
@@ -3673,10 +3642,6 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
36733642 Expression* expression = ParseExpression (false , &classifier, CHECK_OK);
36743643 int lhs_end_pos = scanner ()->location ().end_pos ;
36753644 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE;
3676- is_let_identifier_expression =
3677- expression->IsVariableProxy () &&
3678- expression->AsVariableProxy ()->raw_name () ==
3679- ast_value_factory ()->let_string ();
36803645
36813646 bool is_for_each = CheckInOrOf (&mode, ok);
36823647 if (!*ok) return nullptr ;
@@ -3737,13 +3702,6 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
37373702 Target target (&this ->target_stack_ , loop);
37383703
37393704 // Parsed initializer at this point.
3740- // Detect attempts at 'let' declarations in sloppy mode.
3741- if (!allow_harmony_sloppy_let () && peek () == Token::IDENTIFIER &&
3742- is_sloppy (language_mode ()) && is_let_identifier_expression) {
3743- ReportMessage (MessageTemplate::kSloppyLexical , NULL );
3744- *ok = false ;
3745- return NULL ;
3746- }
37473705 Expect (Token::SEMICOLON, CHECK_OK);
37483706
37493707 Expression* cond = NULL ;
@@ -4039,42 +3997,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
40393997 function_name = ast_value_factory ()->empty_string ();
40403998 }
40413999
4042- // Function declarations are function scoped in normal mode, so they are
4043- // hoisted. In harmony block scoping mode they are block scoped, so they
4044- // are not hoisted.
4045- //
4046- // One tricky case are function declarations in a local sloppy-mode eval:
4047- // their declaration is hoisted, but they still see the local scope. E.g.,
4048- //
4049- // function() {
4050- // var x = 0
4051- // try { throw 1 } catch (x) { eval("function g() { return x }") }
4052- // return g()
4053- // }
4054- //
4055- // needs to return 1. To distinguish such cases, we need to detect
4056- // (1) whether a function stems from a sloppy eval, and
4057- // (2) whether it actually hoists across the eval.
4058- // Unfortunately, we do not represent sloppy eval scopes, so we do not have
4059- // either information available directly, especially not when lazily compiling
4060- // a function like 'g'. We hence rely on the following invariants:
4061- // - (1) is the case iff the innermost scope of the deserialized scope chain
4062- // under which we compile is _not_ a declaration scope. This holds because
4063- // in all normal cases, function declarations are fully hoisted to a
4064- // declaration scope and compiled relative to that.
4065- // - (2) is the case iff the current declaration scope is still the original
4066- // one relative to the deserialized scope chain. Otherwise we must be
4067- // compiling a function in an inner declaration scope in the eval, e.g. a
4068- // nested function, and hoisting works normally relative to that.
4069- Scope* declaration_scope = scope_->DeclarationScope ();
4070- Scope* original_declaration_scope = original_scope_->DeclarationScope ();
4071- Scope* scope = function_type == FunctionLiteral::kDeclaration &&
4072- is_sloppy (language_mode) &&
4073- !allow_harmony_sloppy_function () &&
4074- (original_scope_ == original_declaration_scope ||
4075- declaration_scope != original_declaration_scope)
4076- ? NewScope (declaration_scope, FUNCTION_SCOPE, kind)
4077- : NewScope (scope_, FUNCTION_SCOPE, kind);
4000+ Scope* scope = NewScope (scope_, FUNCTION_SCOPE, kind);
40784001 SetLanguageMode (scope, language_mode);
40794002 ZoneList<Statement*>* body = NULL ;
40804003 int arity = -1 ;
@@ -4249,7 +4172,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
42494172 CheckStrictOctalLiteral (scope->start_position (), scope->end_position (),
42504173 CHECK_OK);
42514174 }
4252- if (is_sloppy (language_mode) && allow_harmony_sloppy_function () ) {
4175+ if (is_sloppy (language_mode)) {
42534176 InsertSloppyBlockFunctionVarBindings (scope, CHECK_OK);
42544177 }
42554178 CheckConflictingVarDeclarations (scope, CHECK_OK);
@@ -4673,9 +4596,6 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
46734596 reusable_preparser_->set_allow_lazy (true );
46744597#define SET_ALLOW (name ) reusable_preparser_->set_allow_##name(allow_##name());
46754598 SET_ALLOW (natives);
4676- SET_ALLOW (harmony_sloppy);
4677- SET_ALLOW (harmony_sloppy_function);
4678- SET_ALLOW (harmony_sloppy_let);
46794599 SET_ALLOW (harmony_do_expressions);
46804600 SET_ALLOW (harmony_function_name);
46814601 SET_ALLOW (harmony_function_sent);
0 commit comments