MMTMMT Docs
Diagnostics

T429

lambda changes the collection it is reading

T429

The lambda mutates the collection the operation is iterating, directly or by passing it to a mutating function, which would change the sequence underneath the iteration. Mutate a different collection, or write a plain for loop.

Failing example

script "conf"
data chart = subscribe(data.ohlcv)
state xs: float[] = float[](4)
on chart.update {
  let ys = xs.map(|x| (xs.pop() ?? 0.0) + x)
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
state xs: float[] = float[](4)
on chart.update {
  let ys = xs.map(|x| x * 2.0)
}

On this page