google / google/closure-compiler
Array constructor with length is not eliminated
Open
feat
good first issue
help wanted
P4
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Consider the code:
```javascript
/** @const {!Array} */
const a = [1];
/** @const {!Array} */
const b = Array(10);
b[0] = 2;
/** @const {!Array} */
const c = [];
c.push(3);
/** @const {!Array} */
const d = Array(10);
d.push(4);
```
When compiled with
```shell
yarn google-closure-compiler -O ADVANCED --js a.js --rewrite_polyfills=false
```
we get
```javascript
Array(10)[0]=2;Array(10).push(4);
```
Arrays created with the `Array(len)` constructor are not eliminated.
google-closure-compiler version: v20230103
Contributor guide
Assessment
This issue has not been assessed yet.