Commit 481bad1f authored by adamk's avatar adamk Committed by Commit bot

Reland shipping of --harmony-destructuring-bind

Also fix CheckConflictingVarDeclarations() to properly handle
legacy const bindings. Without that change enabling the flag
causes code like:

  function f() { const x; var x; }

to throw an early error, rather than wait to throw the error
until f is invoked.

The previous patch ran into problems with the fuzzer; that crash was fixed
(with test coverage added) in https://crrev.com/ceb92ebfdfb561d71038793c02b42aa973f55ec4

BUG=v8:811
LOG=y
TBR=rossberg@chromium.org
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1473243006

Cr-Commit-Position: refs/heads/master@{#32306}
parent dc3442b1
......@@ -211,7 +211,6 @@ DEFINE_IMPLICATION(es_staging, harmony_destructuring_bind)
// Features that are complete (but still behind --harmony/es-staging flag).
#define HARMONY_STAGED(V) \
V(harmony_destructuring_bind, "harmony destructuring") \
V(harmony_regexps, "harmony regular expression extensions") \
V(harmony_sloppy, "harmony features in sloppy mode") \
V(harmony_sloppy_let, "harmony let in sloppy mode")
......@@ -220,6 +219,7 @@ DEFINE_IMPLICATION(es_staging, harmony_destructuring_bind)
#define HARMONY_SHIPPING(V) \
V(harmony_array_includes, "harmony Array.prototype.includes") \
V(harmony_default_parameters, "harmony default parameters") \
V(harmony_destructuring_bind, "harmony destructuring bind") \
V(harmony_object_observe, "harmony Object.observe") \
V(harmony_rest_parameters, "harmony rest parameters") \
V(harmony_concat_spreadable, "harmony isConcatSpreadable") \
......
......@@ -610,7 +610,11 @@ Declaration* Scope::CheckConflictingVarDeclarations() {
int length = decls_.length();
for (int i = 0; i < length; i++) {
Declaration* decl = decls_[i];
if (decl->mode() != VAR && !is_block_scope()) continue;
// We don't create a separate scope to hold the function name of a function
// expression, so we have to make sure not to consider it when checking for
// conflicts (since it's conceptually "outside" the declaration scope).
if (is_function_scope() && decl == function()) continue;
if (IsLexicalVariableMode(decl->mode()) && !is_block_scope()) continue;
const AstRawString* name = decl->proxy()->raw_name();
// Iterate through all scopes until and including the declaration scope.
......@@ -620,11 +624,11 @@ Declaration* Scope::CheckConflictingVarDeclarations() {
// captured in Parser::Declare. The only conflicts we still need to check
// are lexical vs VAR, or any declarations within a declaration block scope
// vs lexical declarations in its surrounding (function) scope.
if (decl->mode() != VAR) current = current->outer_scope_;
if (IsLexicalVariableMode(decl->mode())) current = current->outer_scope_;
do {
// There is a conflict if there exists a non-VAR binding.
Variable* other_var = current->variables_.Lookup(name);
if (other_var != NULL && other_var->mode() != VAR) {
if (other_var != NULL && IsLexicalVariableMode(other_var->mode())) {
return decl;
}
previous = current;
......
......@@ -624,11 +624,6 @@
'js1_5/Regress/regress-417893': [FAIL_OK],
# Unsupported use of "[]" as function parameter. We match JSC.
'js1_5/Regress/regress-416737-01': [FAIL_OK],
'js1_5/Regress/regress-416737-02': [FAIL_OK],
# Illegal escape-sequences in string literals. Has already been fixed
# by most engines (i.e. V8, JSC, Opera and FF).
'ecma/Array/15.4.5.1-1': [FAIL_OK],
......
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