| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index 9113e8c7a4e3ba46b936b38d1f4627ff0c426cf4..eaa1a6c136e7048596e345006837f697c06efb54 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -1071,7 +1071,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
|
| // pre-existing bindings should be made writable, enumerable and
|
| // nonconfigurable if possible, whereas this code will leave attributes
|
| // unchanged if the property already exists.
|
| - InsertSloppyBlockFunctionVarBindings(scope, &ok);
|
| + InsertSloppyBlockFunctionVarBindings(scope, body, &ok);
|
| }
|
| if (ok && (is_strict(language_mode()) || allow_harmony_sloppy())) {
|
| CheckConflictingVarDeclarations(scope_, &ok);
|
| @@ -4315,7 +4315,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
|
| CHECK_OK);
|
| }
|
| if (is_sloppy(language_mode) && allow_harmony_sloppy_function()) {
|
| - InsertSloppyBlockFunctionVarBindings(scope, CHECK_OK);
|
| + InsertSloppyBlockFunctionVarBindings(scope, body, CHECK_OK);
|
| }
|
| if (is_strict(language_mode) || allow_harmony_sloppy()) {
|
| CheckConflictingVarDeclarations(scope, CHECK_OK);
|
| @@ -5003,7 +5003,7 @@ void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) {
|
| }
|
|
|
|
|
| -void Parser::InsertSloppyBlockFunctionVarBindings(Scope* scope, bool* ok) {
|
| +void Parser::InsertSloppyBlockFunctionVarBindings(Scope* scope, ZoneList<Statement*>* body, bool* ok) {
|
| // For each variable which is used as a function declaration in a sloppy
|
| // block,
|
| DCHECK(scope->is_declaration_scope());
|
| @@ -5021,6 +5021,17 @@ void Parser::InsertSloppyBlockFunctionVarBindings(Scope* scope, bool* ok) {
|
| DCHECK(ok); // Based on the preceding check, this should not fail
|
| if (!ok) return;
|
|
|
| + // For testing, insert an initializing assignment to the function
|
| + // setting it to "throwLittleDan".
|
| + VariableProxy* littledanVariable = scope_->NewUnresolved(
|
| + factory(), ast_value_factory()->throwLittleDan_string(), Variable::NORMAL,
|
| + RelocInfo::kNoPosition, RelocInfo::kNoPosition);
|
| + Assignment* littledanAssignment = factory()->NewAssignment(
|
| + Token::ASSIGN, proxy, littledanVariable, RelocInfo::kNoPosition);
|
| + Statement* littledanStatement = factory()->NewExpressionStatement(
|
| + littledanAssignment, RelocInfo::kNoPosition);
|
| + body->InsertAt(0, littledanStatement, zone());
|
| +
|
| // Write in assignments to var for each block-scoped function declaration
|
| auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value);
|
| for (SloppyBlockFunctionStatement* delegate : *delegates) {
|
|
|