Index: src/preparser.cc |
diff --git a/src/preparser.cc b/src/preparser.cc |
index 74e11b1d454b3b33a3f6bcadb18f91476a246f37..246b03a016133abae830abe1f9c02464e20f3baf 100644 |
--- a/src/preparser.cc |
+++ b/src/preparser.cc |
@@ -580,6 +580,7 @@ PreParser::Statement PreParser::ParseVariableDeclarations( |
// Parse binding pattern. |
if (nvars > 0) Consume(Token::COMMA); |
{ |
+ int decl_pos = peek_position(); |
ExpressionClassifier pattern_classifier; |
Token::Value next = peek(); |
PreParserExpression pattern = |
@@ -594,6 +595,20 @@ PreParser::Statement PreParser::ParseVariableDeclarations( |
*ok = false; |
return Statement::Default(); |
} |
+ |
+ bool is_for_iteration_variable = |
+ var_context == kForStatement && |
+ (peek() == Token::IN || PeekContextualKeyword(CStrVector("of"))); |
+ |
+ if (!is_for_iteration_variable && |
+ (pattern.IsObjectLiteral() || pattern.IsArrayLiteral()) && |
+ peek() != Token::ASSIGN) { |
+ ReportMessageAt( |
+ Scanner::Location(decl_pos, scanner()->location().end_pos), |
+ MessageTemplate::kInvalidDestructuringDeclaration); |
+ *ok = false; |
+ return Statement::Default(); |
+ } |
} |
Scanner::Location variable_loc = scanner()->location(); |