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

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

Issue 2697193007: Report unexpected lexical decl also without destructuring (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 | « no previous file | test/message/let-lexical-declaration-destructuring-in-single-statement.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 126037823439150c746188a24b7c076c3e4cdb5d..a22ce83bd0c6a36f7edabab1b5a1b04224298b54 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -4932,12 +4932,16 @@ 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::IDENTIFIER) break;
Dan Ehrenberg 2017/02/17 08:37:14 Another case you can include here is "let {", whic
vabr (Chromium) 2017/02/17 09:52:07 Good idea! Done.
impl()->ReportMessageAt(scanner()->peek_location(),
MessageTemplate::kUnexpectedLexicalDeclaration);
*ok = false;
return impl()->NullStatement();
+ }
default:
break;
}
« no previous file with comments | « no previous file | test/message/let-lexical-declaration-destructuring-in-single-statement.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698