google / google/closure-compiler

Fold comma operation when left argument has no side effects.

Open
#2,803 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

(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

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.