# operator-assignment

Require compound assignment where equivalent

`place = place + value` reads and writes the same stable place and is equivalent to `place += value`.
Instead, you SHOULD use the corresponding compound assignment.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function advance(value: int32): int32 {
    let result = value;
    result = result + 1;
    return result;
}
```

## Accepted

```ds title="main.ds"
function advance(value: int32): int32 {
    let result = value;
    result += 1;
    return result;
}
```

## Prior art

- [ESLint · operator-assignment](https://eslint.org/docs/latest/rules/operator-assignment)

[language/linter/src/rules/style/operator_assignment.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/operator_assignment.rs#L8)
