KScript docs
EN

Error codes

KS5019

A script calls its own main function. main runs by itself once the script's top-level code has run (see The main function), so a call to it in the top-level code runs it a second time. Remove the call; the quick fix does that.

<fn name="main">
  <echo>Hello</echo>
</fn>

<do>@main()</do> <!-- warning: main runs by itself after this, so Hello is printed twice -->
fn main() {
  echo 'Hello'
}

@main()    // warning: main runs by itself after this, so Hello is printed twice

A call inside another function, or in a fn() => @main() kept for later, isn't reported: it runs only when something calls that.