Lyricdev
GitHub

LYR-SEM0021

a missing, duplicated or malformed main

error · spec 04-modules

The entry module has no main, declares it twice, or declares it with parameters or with a return type other than void or int.

Explanation

A program starts at the main of the module the build starts from: fn main(): void or fn main(): int (the exit code), optionally with throws. It takes no parameters — the command-line arguments come from the standard library. A main in any other module is an ordinary function.

Declare exactly one main of that form, and read the arguments through the standard library.

Wrong

fn main(n: int): void {
    let _ = n;
}
fn main(): void {
    let n = 1;
    let _ = n;
}