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

Unified Diff: src/parsing/parser-base.h

Issue 2694003002: Raise SyntaxError on let [ starting an ExpressionStatement (Closed)
Patch Set: Created 3 years, 10 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/messages.h ('k') | test/mjsunit/for.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index 9809071d4789a58da84abfd32420688e0fd2a038..7871ab01483c9b602ae6f9fd90afb9315a7b61a1 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -4996,6 +4996,12 @@ ParserBase<Impl>::ParseExpressionOrLabelledStatement(
ReportUnexpectedToken(Next());
*ok = false;
return impl()->NullStatement();
+ case Token::LET:
+ if (PeekAhead() != Token::LBRACK) break;
+ impl()->ReportMessageAt(scanner()->peek_location(),
+ MessageTemplate::kUnexpectedTokenLetLBrack);
+ *ok = false;
+ return impl()->NullStatement();
default:
break;
}
@@ -5446,6 +5452,13 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
StatementT init = impl()->NullStatement();
+ // "let [" is forbidden in the initializer of the for loop.
+ if (peek() == Token::LET && PeekAhead() == Token::LBRACK) {
+ impl()->ReportMessageAt(scanner()->peek_location(),
+ MessageTemplate::kUnexpectedTokenLetLBrack);
+ *ok = false;
+ return init;
+ }
Dan Ehrenberg 2017/02/13 19:26:57 I'm not sure I agree with your reading of the spec
vabr (Chromium) 2017/02/13 20:14:46 The test failures are due to not restricting this
vabr (Chromium) 2017/02/13 20:29:20 Hm, now I see how I misunderstood your comment and
if (peek() == Token::VAR || peek() == Token::CONST ||
(peek() == Token::LET && IsNextLetKeyword())) {
// The initializer contains declarations.
« no previous file with comments | « src/messages.h ('k') | test/mjsunit/for.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698