google / google/closure-compiler
Fold comma operation when left argument has no side effects.
Open
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
(Using https://closure-compiler.appspot.com/home with Advanced Optimizations.)
Currently, the compiler shows a warning:
```
JSC_USELESS_CODE: Suspicious code. This code lacks side-effects. Is there a bug? at line 1 character 13
console.log((1, 0) > 5)
^
```
However, it doesn't (edit:) _always_ constant-fold the comma operator.
This is folded:
console.log((1,0));
This is not:
console.log((1, 0) > 5)
Output:
console.log(5<(1,0));
Contributor guide
Assessment
This issue has not been assessed yet.