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

Unified Diff: src/preparser.cc

Issue 1219853004: [es6] Initial support for let/const bindings in sloppy mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Updated tests and comments Created 5 years, 5 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
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 08d322b7d9a2b4ceb577667ad874ef54b322d134..abf28c1ddf517e815908450ba59e69281ad86599 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -197,7 +197,7 @@ PreParser::Statement PreParser::ParseStatementListItem(bool* ok) {
}
break;
case Token::LET:
- if (is_strict(language_mode())) {
+ if (allow_let()) {
return ParseVariableStatement(kStatementListItem, ok);
}
break;
@@ -456,7 +456,7 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) {
Expect(Token::LBRACE, CHECK_OK);
Statement final = Statement::Default();
while (peek() != Token::RBRACE) {
- if (is_strict(language_mode())) {
+ if (is_strict(language_mode()) || allow_harmony_sloppy()) {
final = ParseStatementListItem(CHECK_OK);
} else {
final = ParseStatement(CHECK_OK);
@@ -524,12 +524,13 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
// existing pages. Therefore we keep allowing const with the old
// non-harmony semantics in sloppy mode.
Consume(Token::CONST);
- if (is_strict(language_mode())) {
+ if (is_strict(language_mode()) ||
+ (allow_harmony_sloppy() && !allow_legacy_const())) {
DCHECK(var_context != kStatement);
is_strict_const = true;
require_initializer = var_context != kForStatement;
}
- } else if (peek() == Token::LET && is_strict(language_mode())) {
+ } else if (peek() == Token::LET && allow_let()) {
Consume(Token::LET);
DCHECK(var_context != kStatement);
} else {
@@ -869,7 +870,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
if (peek() != Token::SEMICOLON) {
ForEachStatement::VisitMode mode;
if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) ||
- (peek() == Token::LET && is_strict(language_mode()))) {
+ (peek() == Token::LET && allow_let())) {
int decl_count;
Scanner::Location first_initializer_loc = Scanner::Location::invalid();
Scanner::Location bindings_loc = Scanner::Location::invalid();

Powered by Google App Engine
This is Rietveld 408576698