E4067

E4067#

Missing main function in the main package.

In MoonBit, packages are divided into two types: main packages and non-main packages. Non-main packages are often used as libraries to provide functionality to other packages. Main packages, on the other hand, are the entry points of the program. Therefore, a main package should contain a main function serving as the entry point of the program.

Erroneous example#

Suppose in package main:

main/moon.pkg:

options(
  "is-main": true,
)

main/main.mbt:

///|
pub fn helper() -> Unit {
  ()
}

Suggestion#

You can add a main function to the main package:

main/main.mbt:

///|
priv struct ()

///|
fn ::( : ) ->  {
  .0
}

///|
fn main {
  let  = (42)
  (.())
}

Alternatively, you can set the package to be a non-main package by setting "is-main" to false in the package configuration file.

main/moon.pkg:

options(
  "is-main": false,
)