MMTMMT Docs
Diagnostics

T430

collection transform must be a separate statement

T430

map, filter, and reduce calls stand alone as a let initializer, an assignment right-hand side, or a bare call statement. Bind the transform with let first, then use the binding inside the larger expression.

Failing example

script "conf"
data chart = subscribe(data.ohlcv)
plot out = plot.line(title: "out")
state xs: float[] = float[](4)
on chart.update {
  out.plot(xs.reduce(0.0, |acc, x| acc + x))
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
plot out = plot.line(title: "out")
state xs: float[] = float[](4)
on chart.update {
  let total = xs.reduce(0.0, |acc, x| acc + x)
  out.plot(total)
}

On this page