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

Unified Diff: src/parser.cc

Issue 869293002: Lexical declarations should not be allowed in Statement (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update comment a bit Created 5 years, 11 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 | « no previous file | src/preparser.cc » ('j') | src/preparser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 51e79bb14cf1c6519de925d6bb1434e06ccc225f..29e010b87260deabbcba23f52d828e4108ac7ddf 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1711,22 +1711,21 @@ Statement* Parser::ParseStatement(ZoneList<const AstRawString*>* labels,
return ParseFunctionDeclaration(NULL, ok);
}
- case Token::CLASS:
- return ParseClassDeclaration(NULL, ok);
-
case Token::DEBUGGER:
return ParseDebuggerStatement(ok);
case Token::VAR:
- case Token::CONST:
return ParseVariableStatement(kStatement, NULL, ok);
- case Token::LET:
- DCHECK(allow_harmony_scoping());
- if (strict_mode() == STRICT) {
+ case Token::CONST:
+ // In ES6 CONST is not allowed as a Statement , only as a
+ // LexicalDeclaration, however we continue to allow it in sloppy mode for
+ // backwards compatibility.
+ if (strict_mode() == SLOPPY) {
return ParseVariableStatement(kStatement, NULL, ok);
}
- // Fall through.
+
+ // Fall through.
default:
return ParseExpressionOrLabelledStatement(labels, ok);
}
@@ -2438,6 +2437,26 @@ Statement* Parser::ParseExpressionOrLabelledStatement(
// ExpressionStatement | LabelledStatement ::
// Expression ';'
// Identifier ':' Statement
+ //
+ // ExpressionStatement[Yield] :
+ // [lookahead ∉ {{, function, class, let [}] Expression[In, ?Yield] ;
+
+ switch (peek()) {
+ case Token::FUNCTION:
+ case Token::LBRACE:
+ UNREACHABLE(); // Always handled by the callers.
+ case Token::CLASS:
+ ReportUnexpectedToken(Next());
+ *ok = false;
+ return nullptr;
adamk 2015/01/23 20:11:39 Nit: the rest of the code in this file still uses
+
+ // TODO(arv): Handle `let [`
+ // https://code.google.com/p/v8/issues/detail?id=3847
+
+ default:
+ break;
+ }
+
int pos = peek_position();
bool starts_with_idenfifier = peek_any_identifier();
Expression* expr = ParseExpression(true, CHECK_OK);
« no previous file with comments | « no previous file | src/preparser.cc » ('j') | src/preparser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698