# `syntax.for_loop`

Loop written in another language's form.

Area 3, [Logic](../topics/logic.md); not declinable; the next step is usually the agent's.

A loop is `for item in items {`, without brackets. A counting loop has no Jadpo form, so its error has no edit.

```jadpo
type Stock = Int {
    min: 0
}

type OrderLine = Object {
    needed: Stock
}

function stock_total(lines: List<OrderLine>) -> Stock {
    var mut total: Stock = 0
    for (const line of lines) {
        total = Stock(total + line.needed)
    }
    return total
}
```

```text
error: Jadpo writes `for line in lines`, not `for (const line of lines)`
 --> main.jadpo:11:9
   |
11 |     for (const line of lines) {
   |         ^^^^^^^^^^^^^^^^^^^^^ write `for line in lines`
  reason: `for (const item of items)` walks a list in JavaScript and TypeScript, `for (item in items)` in Kotlin, `for (Type item : items)` in Java and `foreach (var item in items)` in C#; Jadpo writes `for item in items {`, without brackets.
  next: Write `for line in lines` (agent)
  rule: syntax.for_loop
  help: https://jadpo.dev/docs/errors/syntax.for_loop

check failed: 1 error, 1 file
```
