google / google/closure-compiler

Incorrect deterministic equality error reported

Open
#2,859 0 comments 0 reactions 1 assignee Claimed by @shicks View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

[repo]

```js
var x = null;
var y = null;

function f() {
if (!x) return;
if (x == y) throw '';
}
```

Error:
```
input0:6: WARNING - condition always evaluates to true
left : None
right: null
if (x == y) throw '';
^^^^^^
```

This is admittedly weird code, but it comes up sometimes with inferred variables when the non-null assignments have not yet been analyzed.

[repro]: https://closure-compiler-debugger.appspot.com/#input0%3Dvar%2520x%2520%253D%2520null%253B%250Avar%2520y%2520%253D%2520null%253B%250A%250Afunction%2520f()%2520%257B%250A%2520%2520if%2520(!x)%2520return%253B%250A%2520%2520if%2520(x%2520%253D%253D%2520y)%2520throw%2520''%253B%250A%257D%26input1%26conformanceConfig%26externs%26refasterjs-template%26CHECK_SYMBOLS%3Dtrue%26MISSING_PROPERTIES%3Dtrue%26TRANSPILE%3Dtrue%26CHECK_TYPES%3Dtrue%26CLOSURE_PASS%3Dtrue%26PRESERVE_TYPE_ANNOTATIONS%3Dtrue%26PRETTY_PRINT%3Dtrue

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.