Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: src/parser.cc

Issue 939063002: [strong] Deprecate for-in (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | src/preparser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | src/preparser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698