Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index bb8cb52b75068f0aee6941880fd7d1ecfe58bd29..fdfa87a0e06f3202a0eeb0050ec435e3b75a3a54 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -2882,9 +2882,14 @@ WhileStatement* Parser::ParseWhileStatement( |
| bool Parser::CheckInOrOf(bool accept_OF, |
|
marja
2015/02/19 12:34:22
... could you move CheckInOrOf to ParserBase, seem
rossberg
2015/02/19 13:23:05
Done.
|
| - ForEachStatement::VisitMode* visit_mode) { |
| + ForEachStatement::VisitMode* visit_mode, bool* ok) { |
| if (Check(Token::IN)) { |
| - *visit_mode = ForEachStatement::ENUMERATE; |
| + if (is_strong(language_mode())) { |
| + ReportMessageAt(scanner()->location(), "strong_for_in"); |
| + *ok = false; |
| + } else { |
| + *visit_mode = ForEachStatement::ENUMERATE; |
| + } |
| return true; |
| } else if (accept_OF && CheckContextualKeyword(CStrVector("of"))) { |
| *visit_mode = ForEachStatement::ITERATE; |
| @@ -3222,7 +3227,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, |
| ForEachStatement::VisitMode mode; |
| int each_pos = position(); |
| - if (name != NULL && CheckInOrOf(accept_OF, &mode)) { |
| + if (name != NULL && CheckInOrOf(accept_OF, &mode, ok)) { |
| + if (!*ok) return nullptr; |
| ForEachStatement* loop = |
| factory()->NewForEachStatement(mode, labels, stmt_pos); |
| Target target(&this->target_stack_, loop); |
| @@ -3259,7 +3265,9 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, |
| ForEachStatement::VisitMode mode; |
| int each_pos = position(); |
| - if (accept_IN && CheckInOrOf(accept_OF, &mode)) { |
| + if (accept_IN && CheckInOrOf(accept_OF, &mode, ok)) { |
| + if (!*ok) return nullptr; |
| + |
| // Rewrite a for-in statement of the form |
| // |
| // for (let/const x in e) b |
| @@ -3321,7 +3329,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, |
| expression->AsVariableProxy()->raw_name() == |
| ast_value_factory()->let_string(); |
| - if (CheckInOrOf(accept_OF, &mode)) { |
| + if (CheckInOrOf(accept_OF, &mode, ok)) { |
| + if (!*ok) return nullptr; |
| expression = this->CheckAndRewriteReferenceExpression( |
| expression, lhs_location, "invalid_lhs_in_for", CHECK_OK); |