# 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

```moonbit
fn values() -> Array[Int] {
  [for _ in 0..<3 => break]
}
```

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.

```moonbit
fn values() -> Array[Int] {
  [for value in 0..<3 => value]
}
```
