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

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

Issue 2697193007: Report unexpected lexical decl also without destructuring (Closed)
Patch Set: Add brace 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
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index b6458a1ea271c39b9136e7496683a8f5396fdaa8..fb9567621f2510e77a7da24f140b78146d3df2e9 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -4950,12 +4950,19 @@ ParserBase<Impl>::ParseExpressionOrLabelledStatement(
ReportUnexpectedToken(Next());
*ok = false;
return impl()->NullStatement();
- case Token::LET:
- if (PeekAhead() != Token::LBRACK) break;
+ case Token::LET: {
+ Token::Value next_next = PeekAhead();
+ // "let" followed by either "[", "{" or an identifier means a lexical
+ // declaration, which should not appear here.
+ if (next_next != Token::LBRACK && next_next != Token::LBRACE &&
+ next_next != Token::IDENTIFIER) {
+ break;
+ }
impl()->ReportMessageAt(scanner()->peek_location(),
MessageTemplate::kUnexpectedLexicalDeclaration);
*ok = false;
return impl()->NullStatement();
+ }
default:
break;
}

Powered by Google App Engine
This is Rietveld 408576698