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

Unified Diff: src/preparser.cc

Issue 1371263003: Prohibit let in lexical bindings (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove messages.js test Created 5 years, 2 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/preparser.h ('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/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 4ff2c95466ba8da859a3100ebcb5e8ae0799deef..4cea6364a6a369bb6306ec95ee707d8fd9b05843 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -534,6 +534,7 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
// BindingPattern '=' AssignmentExpression
bool require_initializer = false;
bool is_strict_const = false;
+ bool lexical = false;
if (peek() == Token::VAR) {
if (is_strong(language_mode())) {
Scanner::Location location = scanner()->peek_location();
@@ -559,10 +560,12 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
DCHECK(var_context != kStatement);
is_strict_const = true;
require_initializer = var_context != kForStatement;
+ lexical = true;
}
} else if (peek() == Token::LET && allow_let()) {
Consume(Token::LET);
DCHECK(var_context != kStatement);
+ lexical = true;
} else {
*ok = false;
return Statement::Default();
@@ -583,6 +586,9 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
PreParserExpression pattern =
ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
ValidateBindingPattern(&pattern_classifier, CHECK_OK);
+ if (lexical) {
+ ValidateLetPattern(&pattern_classifier, CHECK_OK);
+ }
if (!allow_harmony_destructuring() && !pattern.IsIdentifier()) {
ReportUnexpectedToken(next);
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698