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

Unified Diff: src/parsing/parser.cc

Issue 2151433005: Slight cleanup of TryCatch parsing/variable declaration (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/mjsunit/harmony/async-function-stacktrace.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index c947c329d57714cee7f793171c6283465235e70d..44d1a8145880902ce0e8e176b8a887b47c3de532 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -2995,17 +2995,14 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
BlockState block_state(&scope_, block_scope);
Target target(&this->target_stack_, catch_block);
- ExpressionClassifier pattern_classifier(this);
- Expression* pattern =
- ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
- ValidateBindingPattern(&pattern_classifier, CHECK_OK);
-
const AstRawString* name = ast_value_factory()->dot_catch_string();
- bool is_simple = pattern->IsVariableProxy();
- if (is_simple) {
- auto proxy = pattern->AsVariableProxy();
- scope_->RemoveUnresolved(proxy);
- name = proxy->raw_name();
+ Expression* pattern = nullptr;
+ if (peek_any_identifier()) {
+ name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
+ } else {
+ ExpressionClassifier pattern_classifier(this);
+ pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
+ ValidateBindingPattern(&pattern_classifier, CHECK_OK);
}
catch_variable = catch_scope->DeclareLocal(
name, VAR, kCreatedInitialized, Variable::NORMAL);
@@ -3013,8 +3010,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
Expect(Token::RPAREN, CHECK_OK);
ZoneList<const AstRawString*> bound_names(1, zone());
-
- if (!is_simple) {
+ if (pattern != nullptr) {
DeclarationDescriptor descriptor;
descriptor.declaration_kind = DeclarationDescriptor::NORMAL;
descriptor.parser = this;
« no previous file with comments | « no previous file | test/mjsunit/harmony/async-function-stacktrace.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698