# no-self-compare

Disallow comparisons with identical deterministic operands

Repeating the same deterministic operand on both sides usually indicates that one of the intended values was duplicated.
Instead, you SHOULD compare the two intended values or call `.isNaN()` when testing floating-point NaN.

- Category: correctness
- Level: warning
- Fix: none
- Scope: module

## Reported

```ds title="main.ds"
function changed(value: int32): boolean {
    return value !== value;
}
```

## Accepted

```ds title="main.ds"
function changed(left: int32, right: int32): boolean {
    return left !== right;
}
```

## Prior art

- [ESLint · no-self-compare](https://eslint.org/docs/latest/rules/no-self-compare)

[language/linter/src/rules/correctness/no_self_compare.rs:6](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/correctness/no_self_compare.rs#L6)
