Commit 4a4f7175 authored by neis's avatar neis Committed by Commit bot

[parser] Fix bug in destructuring binding for catch.

For variables introduced as part of a catch pattern, we used to set their
"initializer position" to the beginning of the pattern.  This lead to
full-codegen eliminating crucial hole checks when reading such variables
inside the pattern itself.

R=adamk@chromium.org, littledan@chromium.org
BUG=v8:5178

Review-Url: https://codereview.chromium.org/2123953002
Cr-Commit-Position: refs/heads/master@{#37569}
parent 9d865339
......@@ -3017,8 +3017,11 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
descriptor.declaration_pos = pattern->position();
descriptor.initialization_pos = pattern->position();
// Initializer position for variables declared by the pattern.
const int initializer_position = position();
DeclarationParsingResult::Declaration decl(
pattern, pattern->position(),
pattern, initializer_position,
factory()->NewVariableProxy(catch_variable));
Block* init_block =
......
......@@ -854,8 +854,6 @@ class Parser : public ParserBase<ParserTraits> {
Assignment* assignment,
Scope* scope);
void set_initializer_position(int pos) { initializer_position_ = pos; }
private:
PatternRewriter() {}
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
assertThrows(() => {
try { throw {} } catch({a=b, b}) { a+b }
}, ReferenceError);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment