FlowscopeDocs

L015

expressions or blocks nest too deeply

Severity Error

Expressions and blocks may nest at most 128 levels: parentheses inside parentheses, a very long chain like a + b + c + …, if inside if, or a long else if ladder. Scripts are shared between traders, so the compiler refuses source that would exhaust the stack of the computer compiling it. Real scripts stay far below the limit; generated code is the usual cause. After this error the rest of the file is not checked.

Split the expression into let steps, move parts into functions, or turn an else if ladder into a match.

Failing example

Flowscope Script
script "Too deep"
data chart = subscribe(data.ohlcv)
plot p = plot.line(title: "P")
on chart.close {
  p.plot(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((chart.close ?? 0.0)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
}

Fixed example

Flowscope Script
script "Too deep"
data chart = subscribe(data.ohlcv)
plot p = plot.line(title: "P")
on chart.close {
  let close = chart.close ?? 0.0
  p.plot(close)
}