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

Unified Diff: src/parsing/parser.cc

Issue 1911963003: Add flag for disallowing for-in initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added comment Created 4 years, 8 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/flag-definitions.h ('k') | test/mjsunit/harmony/for-in.js » ('j') | no next file with comments »
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 e2e8f92ad9f922a5838b96ddea114da2c24e5c79..62300fde4e1e834b6e047630e7077e869bc61537 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -3500,6 +3500,18 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
if (!IsLexicalVariableMode(parsing_result.descriptor.mode) &&
decl.pattern->IsVariableProxy() && decl.initializer != nullptr) {
++use_counts_[v8::Isolate::kForInInitializer];
+ if (FLAG_harmony_for_in) {
+ // TODO(rossberg): This error is not currently generated in the
+ // preparser, because that would lose some of the use counts
+ // recorded above. Once either the use counter or the flag is
+ // removed, the preparser should be adjusted.
+ ParserTraits::ReportMessageAt(
+ parsing_result.first_initializer_loc,
+ MessageTemplate::kForInOfLoopInitializer,
+ ForEachStatement::VisitModeString(mode));
+ *ok = false;
+ return nullptr;
+ }
const AstRawString* name =
decl.pattern->AsVariableProxy()->raw_name();
VariableProxy* single_var = scope_->NewUnresolved(
« no previous file with comments | « src/flag-definitions.h ('k') | test/mjsunit/harmony/for-in.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698