# prefer-const

Require const for bindings never reassigned after initialization

A `let` binding that is never reassigned permits a write the function does not perform.
Instead, you SHOULD declare the binding with `const`.

`const` freezes directly stored values while preserving the access carried by references.

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

## Reported

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

## Accepted

```ds title="main.ds"
function identity(value: int32): int32 {
    const result = value;
    return result;
}
```

## Prior art

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

[language/linter/src/rules/style/prefer_const.rs:9](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/prefer_const.rs#L9)
