Skip to content

Commit a8840bb

Browse files
Cristian Cavalliofrobots
Cristian Cavalli
authored andcommitted
deps: cherry-pick 3c39bac from V8 upstream
Original commit message: Don't skip hole checks inside patterns in parameter lists Previously, b6e9f625c17f3a688139426771e2cb34fbdcb46e fixed self-assignment in parameters to throw. But it failed to deal with the case of destructuring with defaults. This patch extends that previous approach to always treat the end of a parameter as its initializer position, whether it has an initializer or not. This is the minimal change to make it easy to merge; a follow-up will rename the field of Parameter from "initializer_end_position" to "end_position". BUG=v8:5454 Review-Url: https://codereview/chromium.org/2390943002 Cr-Commit-Position: refs/heads/master@{#39962} PR-URL: #9138 Reviewed-By: targos - Michaël Zasso <[email protected]> Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]> Reviewed-By: jasnell - James M Snell <[email protected]>
1 parent 4f25236 commit a8840bb

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 5
1212
#define V8_MINOR_VERSION 1
1313
#define V8_BUILD_NUMBER 281
14-
#define V8_PATCH_LEVEL 86
14+
#define V8_PATCH_LEVEL 87
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/parsing/parser.cc

+1-5
Original file line numberDiff line numberDiff line change
@@ -4445,9 +4445,6 @@ Block* Parser::BuildParameterInitializationBlock(
44454445
// TODO(adamk): Should this be RelocInfo::kNoPosition, since
44464446
// it's just copying from a temp var to the real param var?
44474447
descriptor.initialization_pos = parameter.pattern->position();
4448-
// The initializer position which will end up in,
4449-
// Variable::initializer_position(), used for hole check elimination.
4450-
int initializer_position = parameter.pattern->position();
44514448
Expression* initial_value =
44524449
factory()->NewVariableProxy(parameters.scope->parameter(i));
44534450
if (parameter.initializer != nullptr) {
@@ -4465,7 +4462,6 @@ Block* Parser::BuildParameterInitializationBlock(
44654462
condition, parameter.initializer, initial_value,
44664463
RelocInfo::kNoPosition);
44674464
descriptor.initialization_pos = parameter.initializer->position();
4468-
initializer_position = parameter.initializer_end_position;
44694465
}
44704466

44714467
Scope* param_scope = scope_;
@@ -4490,7 +4486,7 @@ Block* Parser::BuildParameterInitializationBlock(
44904486
{
44914487
BlockState block_state(&scope_, param_scope);
44924488
DeclarationParsingResult::Declaration decl(
4493-
parameter.pattern, initializer_position, initial_value);
4489+
parameter.pattern, parameter.initializer_end_position, initial_value);
44944490
PatternRewriter::DeclareAndInitializeVariables(param_block, &descriptor,
44954491
&decl, nullptr, CHECK_OK);
44964492
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2016 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
assertThrows(function(...[b = !b]) { }, ReferenceError);
6+
assertThrows(() => (function([b = !b]) { })([]), ReferenceError);
7+
assertThrows(() => (function({b = !b}) { })({}), ReferenceError);
8+
9+
assertThrows((...[b = !b]) => { }, ReferenceError);
10+
assertThrows(() => (([b = !b]) => { })([]), ReferenceError);
11+
assertThrows(() => (({b = !b}) => { })({}), ReferenceError);

0 commit comments

Comments
 (0)