# no-diverging-subexpression

Disallow diverging operations inside continuing expressions

A diverging operand prevents the surrounding expression from reaching operations that follow it.
Instead, you SHOULD place the diverging operation in explicit control flow.

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

## Reported

```ds title="main.ds"
declare function stop(): never;

function require(active: boolean): boolean {
    return active || stop();
}
```

## Accepted

```ds title="main.ds"
declare function stop(): never;

function require(active: boolean): boolean {
    if (!active) {
        stop();
    }
    return true;
}
```

## Prior art

- [Clippy · diverging_sub_expression](https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression)

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