google / google/closure-compiler

Failing to optimize getprop

Open
#3,503 1 comment 0 reactions 0 assignees View on GitHub
internal-issue-created triage-done
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Closure Compiler with advanced optimizations fails to optimize the expression `{a:0}.a` to `0` in some cases.

When running:
```bat
echo console.log({a:0}.a) | java -jar closure-compiler-v20191027.jar -O ADVANCED
```
I get `console.log({a:0}.a);`

but when running:
```bat
echo console.log({a:0}.a===0) | java -jar closure-compiler-v20191027.jar -O ADVANCED
```
I get `console.log(!0);`.

It seems that the compiler knows that `{a:0}.a` can be reduced to `0`, but doesn't always do it for no apparent reason.

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.