Fix completion value of empty catch block in the presence of destructuring.
R=adamk@chromium.org BUG= Review URL: https://codereview.chromium.org/1767063002 Cr-Commit-Position: refs/heads/master@{#34575}
This commit is contained in:
parent
b18707b584
commit
998a6e5b92
@ -3101,8 +3101,11 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
|
||||
pattern, pattern->position(),
|
||||
factory()->NewVariableProxy(catch_variable));
|
||||
|
||||
Block* init_block =
|
||||
factory()->NewBlock(nullptr, 8, true, RelocInfo::kNoPosition);
|
||||
PatternRewriter::DeclareAndInitializeVariables(
|
||||
catch_block, &descriptor, &decl, nullptr, CHECK_OK);
|
||||
init_block, &descriptor, &decl, nullptr, CHECK_OK);
|
||||
catch_block->statements()->Add(init_block, zone());
|
||||
}
|
||||
|
||||
Expect(Token::LBRACE, CHECK_OK);
|
||||
|
@ -17,6 +17,8 @@ void Parser::PatternRewriter::DeclareAndInitializeVariables(
|
||||
ZoneList<const AstRawString*>* names, bool* ok) {
|
||||
PatternRewriter rewriter;
|
||||
|
||||
DCHECK(block->ignore_completion_value());
|
||||
|
||||
rewriter.scope_ = declaration_descriptor->scope;
|
||||
rewriter.parser_ = declaration_descriptor->parser;
|
||||
rewriter.context_ = BINDING;
|
||||
@ -358,7 +360,7 @@ void Parser::PatternRewriter::VisitRewritableExpression(
|
||||
PatternContext old_context = SetAssignmentContextIfNeeded(initializer);
|
||||
int pos = assign->position();
|
||||
Block* old_block = block_;
|
||||
block_ = factory()->NewBlock(nullptr, 8, false, pos);
|
||||
block_ = factory()->NewBlock(nullptr, 8, true, pos);
|
||||
Variable* temp = nullptr;
|
||||
Expression* pattern = assign->target();
|
||||
Expression* old_value = current_value_;
|
||||
|
@ -1131,4 +1131,7 @@
|
||||
assertEquals("hello", foo);
|
||||
assertEquals("world", bar);
|
||||
assertEquals(42, baz);
|
||||
|
||||
assertEquals(undefined, eval('try {throw {foo: 1, bar: 2}} catch({foo}) {}'));
|
||||
assertEquals(undefined, eval('try {throw [1, 2, 3]} catch([x]) {}'));
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user