# E4211

Compiler diagnostic name: `control_in_list_comprehension`.

Control flow is not allowed inside a list comprehension.

A list comprehension builds a new collection from the elements produced by its
clauses. Control operations such as `break`, `continue`, `return`, `raise`, and
`async` control do not have a surrounding loop or function boundary inside the
comprehension body that can consume them.

## Erroneous example

```{literalinclude} /sources/error_codes/4211_error/top.mbt
:language: moonbit
```

The `break` appears inside the list comprehension body, so MoonBit reports an
error.

## Suggestion

Move the control flow outside the comprehension, or rewrite the code as an
explicit loop.

```{literalinclude} /sources/error_codes/4211_fixed/top.mbt
:language: moonbit
```
