Commit e0f2e5a5 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

Revert "Set .name of anonymous functions on the RHS of logical assignment."

This reverts commit c342ba82.

Reason for revert: Incorrectly parsed destructuring + logical assignment

Original change's description:
> Set .name of anonymous functions on the RHS of logical assignment.
> 
> https://github.com/tc39/proposal-logical-assignment/pull/24 reached
> consensus in June TC39.
> 
> Drive-by refactoring of testing for logical assignment ops using
> IsInRange.
> 
> Bug: v8:10579
> Change-Id: I5a203ba552a905cd28f75c5d223998431a1966ce
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2225809
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Commit-Queue: Shu-yu Guo <syg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#68101}

TBR=marja@chromium.org,syg@chromium.org

Change-Id: I7992941bb31ad063611a45a65d20517803910475
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:10579
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2227059Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68115}
parent 76debfda
......@@ -2755,7 +2755,8 @@ ParserBase<Impl>::ParseAssignmentExpressionCoverGrammar() {
Token::Value op = peek();
if (!Token::IsArrowOrAssignmentOp(op)) return expression;
if (Token::IsLogicalAssignmentOp(op) &&
if ((op == Token::ASSIGN_NULLISH || op == Token::ASSIGN_OR ||
op == Token::ASSIGN_AND) &&
!flags().allow_harmony_logical_assignment()) {
return expression;
}
......@@ -2829,16 +2830,12 @@ ParserBase<Impl>::ParseAssignmentExpressionCoverGrammar() {
ExpressionT right = ParseAssignmentExpression();
if (op == Token::ASSIGN || Token::IsLogicalAssignmentOp(op)) {
if (op == Token::ASSIGN) {
// We try to estimate the set of properties set by constructors. We define a
// new property whenever there is an assignment to a property of 'this'. We
// should probably only add properties if we haven't seen them before.
// Otherwise we'll probably overestimate the number of properties.
//
// Do not count logical assignments, because they are conditional.
if (op == Token::ASSIGN && impl()->IsThisProperty(expression)) {
function_state_->AddProperty();
}
if (impl()->IsThisProperty(expression)) function_state_->AddProperty();
impl()->CheckAssigningFunctionLiteralToProperty(expression, right);
......
......@@ -284,10 +284,6 @@ class V8_EXPORT_PRIVATE Token {
return base::IsInRange(token, INIT, ASSIGN_SUB);
}
static bool IsLogicalAssignmentOp(Value token) {
return base::IsInRange(token, ASSIGN_NULLISH, ASSIGN_AND);
}
static bool IsBinaryOp(Value op) { return base::IsInRange(op, COMMA, SUB); }
static bool IsCompareOp(Value op) { return base::IsInRange(op, EQ, IN); }
......
// Copyright 2020 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.
// Flags: --harmony-logical-assignment
{
let x = undefined;
x ??= function() {};
assertEquals(x.name, "x");
}
{
let y = false;
y ||= function() {};
assertEquals(y.name, "y");
}
{
let z = true;
z &&= function() {};
assertEquals(z.name, "z");
}
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