# no-invalid-clamp

Disallow clamp calls with invalid constant bounds

A clamp traps when its lower bound exceeds its upper bound or either bound is NaN.
Instead, you MUST pass ordered bounds that are not NaN.

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

## Reported

```ds title="main.ds"
function bounded(value: int32): int32 {
    return value.clamp(10, 0);
}
```

## Accepted

```ds title="main.ds"
function bounded(value: int32): int32 {
    return value.clamp(0, 10);
}
```

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