Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 753391193bf03667a685a24161b83e53ca3ecbda..65b4d7ee896026a780e4342588d00f5335db7549 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -2217,6 +2217,28 @@ Statement* Parser::ParseFunctionDeclaration( |
| factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos); |
| Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); |
| if (names) names->Add(name, zone()); |
| + |
| + // For sloppy function in block we also add a var binding that gets assigned |
| + // to at the location of the FunctionDeclaration -- but only if introducing |
| + // this var binding does not lead to an early error. |
| + if (is_sloppy(language_mode()) && scope_->is_block_scope() && |
| + allow_harmony_sloppy()) { |
| + VariableProxy* var_proxy = NewUnresolved(name, VAR); |
| + Declaration* declaration = |
| + factory()->NewVariableDeclaration(var_proxy, VAR, scope_, pos); |
| + bool var_ok = true; |
| + Declare(declaration, DeclarationDescriptor::NORMAL, true, &var_ok); |
|
arv (Not doing code reviews)
2015/07/10 12:56:12
I was wondering if this actually reports an error.
|
| + if (!var_ok) { |
| + scope_->RemoveUnresolved(var_proxy); |
| + } else { |
| + // At the location of the FunctionDeclaration we assign to the var |
| + // binding. |
| + Assignment* assignment = factory()->NewAssignment( |
| + Token::ASSIGN, var_proxy, NewUnresolved(name, mode), pos); |
| + return factory()->NewExpressionStatement(assignment, |
| + RelocInfo::kNoPosition); |
| + } |
| + } |
| return factory()->NewEmptyStatement(RelocInfo::kNoPosition); |
| } |