MMTMMT Docs
Diagnostics

P026

ternary broken before `?` or `:`

P026

A newline ends the statement when the expression before it is complete, so a line may not begin with ? or :. Break the ternary after the operator instead: end the line with ? or : and continue on the next line.

Failing example

script "example"
data chart = subscribe(data.ohlcv)
state y = 0.0
on chart.update {
  let c = chart.close ?? 0.0
  y = c > 1.0
    ? c
    : 0.0
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
state y = 0.0
on chart.update {
  let c = chart.close ?? 0.0
  y = c > 1.0 ?
    c :
    0.0
}

On this page