# E4211

Compiler diagnostic name: `control_in_list_comprehension`.

`return`, `break`, `continue`, and error-producing calls are not allowed inside
a list comprehension whose result type is `Iter`.

An `Iter` comprehension is lazy: its body runs later, when the iterator is
consumed. Control-flow operations that jump out of the surrounding function or
loop, or calls that need immediate error propagation, cannot be preserved safely
across that lazy boundary.

## Erroneous example

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

## Suggestion

Keep the comprehension body as a normal value-producing expression. If you need
early exit, use an eager collection target or write an explicit loop around the
iterator consumption.

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