KScript docs
EN

Error codes

KS2006

A fn is printed instead of called. Printing a fn, or filling one into text, shows its own code, because nothing calls it. This mostly happens with a pipe: a fn's body runs to the end of the line, so |> call(...) after it becomes part of the body. Put the fn in brackets so the call is made on it. The quick fix does that.

<echo value="fn(width, height) => $width * $height |> call(6, 7)" /> <!-- warning: prints the fn's code -->
<echo value="(fn(width, height) => $width * $height)->call(6, 7)" /> <!-- right: 42 -->
<echo value="(fn(width, height) => $width * $height) |> call(6, 7)" /> <!-- right: 42, the brackets end the fn -->
echo fn(width, height) => $width * $height |> call(6, 7)      // warning: prints the fn's code
echo (fn(width, height) => $width * $height)->call(6, 7)      // right: 42
echo (fn(width, height) => $width * $height) |> call(6, 7)    // right: 42, the brackets end the fn