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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 4914 matching lines...) Expand 10 before | Expand all | Expand 10 after
4925 int pos = peek_position(); 4925 int pos = peek_position();
4926 4926
4927 switch (peek()) { 4927 switch (peek()) {
4928 case Token::FUNCTION: 4928 case Token::FUNCTION:
4929 case Token::LBRACE: 4929 case Token::LBRACE:
4930 UNREACHABLE(); // Always handled by the callers. 4930 UNREACHABLE(); // Always handled by the callers.
4931 case Token::CLASS: 4931 case Token::CLASS:
4932 ReportUnexpectedToken(Next()); 4932 ReportUnexpectedToken(Next());
4933 *ok = false; 4933 *ok = false;
4934 return impl()->NullStatement(); 4934 return impl()->NullStatement();
4935 case Token::LET: 4935 case Token::LET: {
4936 if (PeekAhead() != Token::LBRACK) break; 4936 Token::Value next_next = PeekAhead();
4937 // "let" followed by either "[" or an identifier means a lexical
4938 // declaration, which should not appear here.
4939 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.
4937 impl()->ReportMessageAt(scanner()->peek_location(), 4940 impl()->ReportMessageAt(scanner()->peek_location(),
4938 MessageTemplate::kUnexpectedLexicalDeclaration); 4941 MessageTemplate::kUnexpectedLexicalDeclaration);
4939 *ok = false; 4942 *ok = false;
4940 return impl()->NullStatement(); 4943 return impl()->NullStatement();
4944 }
4941 default: 4945 default:
4942 break; 4946 break;
4943 } 4947 }
4944 4948
4945 bool starts_with_identifier = peek_any_identifier(); 4949 bool starts_with_identifier = peek_any_identifier();
4946 ExpressionT expr = ParseExpression(true, CHECK_OK); 4950 ExpressionT expr = ParseExpression(true, CHECK_OK);
4947 if (peek() == Token::COLON && starts_with_identifier && 4951 if (peek() == Token::COLON && starts_with_identifier &&
4948 impl()->IsIdentifier(expr)) { 4952 impl()->IsIdentifier(expr)) {
4949 // The whole expression was a single identifier, and not, e.g., 4953 // The whole expression was a single identifier, and not, e.g.,
4950 // something starting with an identifier or a parenthesized identifier. 4954 // something starting with an identifier or a parenthesized identifier.
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
5847 } 5851 }
5848 5852
5849 #undef CHECK_OK 5853 #undef CHECK_OK
5850 #undef CHECK_OK_CUSTOM 5854 #undef CHECK_OK_CUSTOM
5851 #undef CHECK_OK_VOID 5855 #undef CHECK_OK_VOID
5852 5856
5853 } // namespace internal 5857 } // namespace internal
5854 } // namespace v8 5858 } // namespace v8
5855 5859
5856 #endif // V8_PARSING_PARSER_BASE_H 5860 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« 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