| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index d993d20595de80567f267e8410dfe77edcbe450c..51d665ad5596c98062ee5bf392e12e360f44aedc 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -3617,13 +3617,13 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
|
|
|
| DCHECK(parsing_result.declarations.length() == 1);
|
| Block* init_block = nullptr;
|
| + const AstRawString* name = parsing_result.SingleName();
|
|
|
| // special case for legacy for (var/const x =.... in)
|
| if (!IsLexicalVariableMode(parsing_result.descriptor.mode) &&
|
| parsing_result.declarations[0].initializer != nullptr) {
|
| VariableProxy* single_var = scope_->NewUnresolved(
|
| - factory(), parsing_result.SingleName(), Variable::NORMAL,
|
| - each_beg_pos, each_end_pos);
|
| + factory(), name, Variable::NORMAL, each_beg_pos, each_end_pos);
|
| init_block = factory()->NewBlock(
|
| nullptr, 2, true, parsing_result.descriptor.declaration_pos);
|
| init_block->AddStatement(
|
| @@ -3636,6 +3636,16 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
|
| zone());
|
| }
|
|
|
| + // For some reason, we can't bind over catch parameters in for-of.
|
| + if (mode == ForEachStatement::ITERATE &&
|
| + IsDeclaredAsCatchParameter(scope_, name)) {
|
| + ParserTraits::ReportMessageAt(parsing_result.first_initializer_loc,
|
| + MessageTemplate::kVarRedeclaration,
|
| + name);
|
| + *ok = false;
|
| + return nullptr;
|
| + }
|
| +
|
| // Rewrite a for-in/of statement of the form
|
| //
|
| // for (let/const/var x in/of e) b
|
| @@ -4816,6 +4826,13 @@ void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) {
|
| }
|
| }
|
|
|
| +bool Parser::IsDeclaredAsCatchParameter(Scope* scope,
|
| + const AstRawString* name) {
|
| + for (; scope != NULL; scope = scope->outer_scope())
|
| + if (scope->is_catch_scope() && scope->LookupLocal(name)) return true;
|
| + return false;
|
| +}
|
| +
|
|
|
| // ----------------------------------------------------------------------------
|
| // Parser support
|
|
|