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

Unified Diff: src/parsing/preparser.cc

Issue 1602823003: [parser] Disallow Expression in for..of statements (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporating latest review feedback Created 4 years, 11 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/parsing/parser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index 64511acc39a30bd875739eafcd4af0bae61fed6a..b04fa792249f81e279f70c039335e26e2187d003 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -950,7 +950,16 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
*ok = false;
return Statement::Default();
}
- ParseExpression(true, CHECK_OK);
+
+ if (mode == ForEachStatement::ITERATE) {
+ ExpressionClassifier classifier;
+ Expression enumerable =
+ ParseAssignmentExpression(true, &classifier, CHECK_OK);
+ PreParserTraits::RewriteNonPattern(enumerable, &classifier, CHECK_OK);
+ } else {
+ ParseExpression(true, CHECK_OK);
+ }
+
Expect(Token::RPAREN, CHECK_OK);
ParseSubStatement(CHECK_OK);
return Statement::Default();
@@ -980,7 +989,16 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor,
kSyntaxError, CHECK_OK);
}
- ParseExpression(true, CHECK_OK);
+
+ if (mode == ForEachStatement::ITERATE) {
+ ExpressionClassifier classifier;
+ Expression enumerable =
+ ParseAssignmentExpression(true, &classifier, CHECK_OK);
+ PreParserTraits::RewriteNonPattern(enumerable, &classifier, CHECK_OK);
+ } else {
+ ParseExpression(true, CHECK_OK);
+ }
+
Expect(Token::RPAREN, CHECK_OK);
ParseSubStatement(CHECK_OK);
return Statement::Default();
« no previous file with comments | « src/parsing/parser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698