Chromium Code Reviews| Index: src/parsing/parser.cc |
| diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
| index 413903b49a044d8880aa6dde996cf7783a7982a9..905997abcdfd24dc30f7057635bc310a5d9afab6 100644 |
| --- a/src/parsing/parser.cc |
| +++ b/src/parsing/parser.cc |
| @@ -2999,40 +2999,40 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
| catch_scope = NewScope(scope_, CATCH_SCOPE); |
| catch_scope->set_start_position(scanner()->location().beg_pos); |
| - 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(); |
| - } |
| - |
| - catch_variable = catch_scope->DeclareLocal(name, VAR, kCreatedInitialized, |
| - Variable::NORMAL); |
| - |
| - Expect(Token::RPAREN, CHECK_OK); |
| - |
| { |
| CollectExpressionsInTailPositionToListScope |
| collect_tail_call_expressions_scope( |
| function_state_, &tail_call_expressions_in_catch_block); |
| BlockState block_state(&scope_, catch_scope); |
| - // TODO(adamk): Make a version of ParseBlock that takes a scope and |
| - // a block. |
| catch_block = |
| factory()->NewBlock(nullptr, 16, false, RelocInfo::kNoPosition); |
| - Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); |
| + // Create a block scope to hold any lexical declarations created |
| + // as part of destructuring the catch parameter. |
| + Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); |
| block_scope->set_start_position(scanner()->location().beg_pos); |
| { |
| 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(); |
| + } |
| + catch_variable = catch_scope->DeclareLocal( |
| + name, VAR, kCreatedInitialized, Variable::NORMAL); |
| + |
| + Expect(Token::RPAREN, CHECK_OK); |
| + |
| if (!is_simple) { |
| DeclarationDescriptor descriptor; |
| descriptor.declaration_kind = DeclarationDescriptor::NORMAL; |
| @@ -3054,6 +3054,8 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
| catch_block->statements()->Add(init_block, zone()); |
| } |
| + // TODO(adamk): This should call ParseBlock in order to properly |
| + // add an additional block scope for the catch body. |
|
neis
2016/06/30 06:47:05
Is this related to the remaining test262 failure?
adamk
2016/06/30 16:02:10
Yes, Kevin will fix this in his patch which fixes
|
| Expect(Token::LBRACE, CHECK_OK); |
| while (peek() != Token::RBRACE) { |
| Statement* stat = ParseStatementListItem(CHECK_OK); |