google / google/closure-compiler

Poor constant propagation through destructuring assignments

Open
#4,219 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Google closure struggles with constant propagation through destructing assignments, which, unfortunately happens very frequently in modern js code.

```javascript filename:a.js
const { A: a, B: b } = { A: 1, B: 2 }
console.log(a, b);
```
`google-closure-compiler --js a.js -O ADVANCED` outputs
```javascript
const {g:a,h:b}={g:1,h:2};console.log(a,b);
```

Many function call happen through "object pattern" parameters in modern js and google closure does no constant propagation through them nor does it have "re-write to normal params" kind of pass.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.