Diagnostics
T432
save the value in a variable before changing it
T432
This method changes a value. Save the value in a local or state variable before calling the method. If you read the value from a collection, write the changed value back afterward.
Failing example
script "conf"
type Zone {
lo: float
hi: float
fn grow(by: float) { self.hi += by }
}
fn makeZone() -> Zone { return Zone { lo: 0.0, hi: 1.0 } }
data chart = subscribe(data.ohlcv)
on chart.update {
makeZone().grow(by: 1.0)
}Corrected example
script "fixed"
type Zone {
lo: float
hi: float
fn grow(by: float) { self.hi += by }
}
data chart = subscribe(data.ohlcv)
state zone: Zone = Zone { lo: 0.0, hi: 1.0 }
on chart.update {
zone.grow(by: 1.0)
}