docs

#E0036: invalid program entry point

A program starts either at the top-level statements of main.nabi or at fn main, not both; other files hold definitions only. fn main takes no parameters, is not generic or unsafe, and returns () or i32; it may be async, and a throws main returns ().

nabi
fn main(args: List<str>) {}
error[E0036]: `fn main`: takes no parameters; read arguments through `std::env`
  --> main.nabi:1:1
   |
 1 | fn main(args: List<str>) {}
   | ^^

Read the arguments through std::env:

nabi
use std::env;

fn main() {
    println(f"{env::args().len() > 0}");
}
true

A fn main that returns another type is E0036 too, with the message `fn main`: must return `()` or `i32` (4.16).

Related: E0018 return with a value in top-level statements, E0023 invalid function signature

Found a mistake? Edit this page on GitHub. Last updated