Skip to content

Incorrect DCE of assignment to destructered parameter field with ES_2015 or higher #3499

Closed

Description

Code sample:

function installBaa({ obj }) {
    obj.baa = 'foo';
}

const obj = {};
installBaa({ obj });
console.log(obj.baa);

Command:

java -jar compiler.jar --js test.js -O ADVANCED --language_out ECMASCRIPT_2015

Version: v20191027

Expected output: (as output by --language_out ECMASCRIPT5)

console.log({a:"foo"}.a);

Actual output:

'use strict';console.log({}.a);

It looks like CC is losing the assignment when the target language is ECMASCRIPT_2015 or higher.

The following non-destructered parameter works as expected:

function installRoutes(x) {
    x.obj.baa = 'foo';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

internal-issue-createdAn internal Google issue has been created to track this GitHub issueAn internal Google issue has been created to track this GitHub issuetriage-doneHas been reviewed by someone on triage rotation.Has been reviewed by someone on triage rotation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions