main may take no parameters or args: [str], and return nothing, int (the exit code),
()! or int! (an error prints and exits with 1). Other signatures can't be called by the
runtime.
Wrong#
fn main(n: int) {
print(n)
}Fixed#
fn main(args: [str]) {
print(args.len())
}Common causes#
- Expecting parsed arguments: take
args: [str]and parse withint.parse(args[1]). - Returning a type other than
int,()or their!forms.