Skip to main content

Module program

Module program 

Source
Expand description

A program’s entry point: the module a manifest’s main names, held to Programs.

That section asks three things of a package whose manifest has main: the name is a module under src/, the module exposes a value called main, and that value has type Task (). The first is about the manifest and has no place in any source to point at, so it is ManifestError::MainModuleNotFound. The other two are about the module, and are this module’s Error.

check reads a module that already checked. The type it compares is the one inference solved for main — ir::Declaration::tpe — or, for a main the typer left unchecked, the one its annotation declares. Task is recognised by the qualified name of its declaration in zelkova-core, never by spelling, so a union some other module calls Task is not it.

§Which packages are checked

Every package of the build whose manifest has main, not only the one the compiler was pointed at: compile_in_build runs the check, and it runs for each package of the build alike. A package is a program because its own manifest says so, and whether that manifest is right cannot depend on which package started the build: a dependency whose main names nothing is as broken as a root whose main names nothing, and would fail the moment it was compiled on its own. Checking it only as the root would make one package valid in one build and invalid in another.

Enums§

Error
What is wrong with the module a manifest’s main names.

Functions§

check
Check that module is fit to be a program’s entry point: it exposes main, and main’s solved type is Task.Task () as zelkova-core declares it.