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

Unified Diff: src/parsing/parser.cc

Issue 1602823003: [parser] Disallow Expression in for..of statements (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Correcting a typo 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 | « no previous file | src/parsing/preparser.cc » ('j') | test/cctest/test-parsing.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 0048b8da698b718cc01671f52ab659b905427c2e..f57e424af2e05f3a4610b16e476010129e44dc84 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -3676,7 +3676,14 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
factory()->NewForEachStatement(mode, labels, stmt_pos);
Target target(&this->target_stack_, loop);
- Expression* enumerable = ParseExpression(true, CHECK_OK);
+ Expression* enumerable;
+ if (mode == ForEachStatement::ITERATE) {
+ ExpressionClassifier classifier;
+ enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK);
+ ParserTraits::RewriteNonPattern(enumerable, &classifier, CHECK_OK);
adamk 2016/01/20 00:35:57 I think the calling convention here is to assign i
mike3 2016/01/20 17:55:40 Acknowledged.
+ } else {
+ enumerable = ParseExpression(true, CHECK_OK);
+ }
Expect(Token::RPAREN, CHECK_OK);
@@ -3791,7 +3798,15 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
factory()->NewForEachStatement(mode, labels, stmt_pos);
Target target(&this->target_stack_, loop);
- Expression* enumerable = ParseExpression(true, CHECK_OK);
+ Expression* enumerable;
+ if (mode == ForEachStatement::ITERATE) {
+ ExpressionClassifier classifier;
+ enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK);
+ ParserTraits::RewriteNonPattern(enumerable, &classifier, CHECK_OK);
adamk 2016/01/20 00:35:57 Same note here.
mike3 2016/01/20 17:55:40 Acknowledged.
+ } else {
+ enumerable = ParseExpression(true, CHECK_OK);
+ }
+
Expect(Token::RPAREN, CHECK_OK);
// Make a block around the statement in case a lexical binding
« no previous file with comments | « no previous file | src/parsing/preparser.cc » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698