Commit bdf5b39f authored by adamk's avatar adamk Committed by Commit bot

Stop emitting kSloppyLexical errors when --harmony-sloppy-let is enabled

This changes the error message for code like:

  if (false) let x;

from "Block-scoped declarations (let, const, function, class) not yet supported outside strict mode"
to "Unexpected identifier" (pointing at |x|).

Review URL: https://codereview.chromium.org/1356783002

Cr-Commit-Position: refs/heads/master@{#30834}
parent 7864c35a
...@@ -2713,7 +2713,8 @@ Statement* Parser::ParseExpressionOrLabelledStatement( ...@@ -2713,7 +2713,8 @@ Statement* Parser::ParseExpressionOrLabelledStatement(
// Parsed expression statement, followed by semicolon. // Parsed expression statement, followed by semicolon.
// Detect attempts at 'let' declarations in sloppy mode. // Detect attempts at 'let' declarations in sloppy mode.
if (peek() == Token::IDENTIFIER && expr->AsVariableProxy() != NULL && if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
expr->AsVariableProxy() != NULL &&
expr->AsVariableProxy()->raw_name() == expr->AsVariableProxy()->raw_name() ==
ast_value_factory()->let_string()) { ast_value_factory()->let_string()) {
ReportMessage(MessageTemplate::kSloppyLexical, NULL); ReportMessage(MessageTemplate::kSloppyLexical, NULL);
...@@ -3792,8 +3793,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, ...@@ -3792,8 +3793,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
// Parsed initializer at this point. // Parsed initializer at this point.
// Detect attempts at 'let' declarations in sloppy mode. // Detect attempts at 'let' declarations in sloppy mode.
if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) && if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
is_let_identifier_expression) { is_sloppy(language_mode()) && is_let_identifier_expression) {
ReportMessage(MessageTemplate::kSloppyLexical, NULL); ReportMessage(MessageTemplate::kSloppyLexical, NULL);
*ok = false; *ok = false;
return NULL; return NULL;
......
...@@ -700,8 +700,9 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) { ...@@ -700,8 +700,9 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) {
} }
// Parsed expression statement. // Parsed expression statement.
// Detect attempts at 'let' declarations in sloppy mode. // Detect attempts at 'let' declarations in sloppy mode.
if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) && if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
expr.IsIdentifier() && expr.AsIdentifier().IsLet()) { is_sloppy(language_mode()) && expr.IsIdentifier() &&
expr.AsIdentifier().IsLet()) {
ReportMessage(MessageTemplate::kSloppyLexical, NULL); ReportMessage(MessageTemplate::kSloppyLexical, NULL);
*ok = false; *ok = false;
return Statement::Default(); return Statement::Default();
...@@ -960,8 +961,8 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) { ...@@ -960,8 +961,8 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
// Parsed initializer at this point. // Parsed initializer at this point.
// Detect attempts at 'let' declarations in sloppy mode. // Detect attempts at 'let' declarations in sloppy mode.
if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) && if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
is_let_identifier_expression) { is_sloppy(language_mode()) && is_let_identifier_expression) {
ReportMessage(MessageTemplate::kSloppyLexical, NULL); ReportMessage(MessageTemplate::kSloppyLexical, NULL);
*ok = false; *ok = false;
return Statement::Default(); return Statement::Default();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment