README

marianoguerra/wax/compile does not have a README file

#
CompileError

What can stop a checked module from becoming output.

Three packages sit on this path and each raises its own error: the lowering to the wasm module model, the binary encoder, and the text printer. A caller handed the open Error type can only print what it catches; naming the three lets it match on them, and says up front that there is no fourth.

None of these are a rejected module. A module the checker rejected is reported through Session::reports and rejected before anything is lowered -- these are the lowering's own gaps, and reaching one on a module that checked clean is a bug in this port rather than in the input. The one exception is LowerError::AmbiguousBinding, which only a generated tree can reach and which names what the generator has to fix.

#
Checked

A module that has been through the type checker.

It holds the four things the lowering needs and that a caller would otherwise have to keep together by hand: the session (for its type store), the module context the checker built, the source AST, and the per-node inferred types the checker left alongside it. The lowering reads the types off typed, which is the entire interface between the two stages.

Holding a Checked is NOT a claim that the module is valid -- see Session::check. Lowering one the checker rejected raises, or produces a module derived from something known to be wrong.

#
Checked::to_bytes

fn Checked::to_bytes(self : Checked) -> Bytes raise CompileError

Encode to a .wasm binary.

#
Checked::to_module

Lower to the wasm module model, shared by both output forms.

keep_conditionals retains the conditional sections rather than resolving them, which only the text form wants: a module with an unresolved conditional has no single binary form, and that is what a conditional is for.

#
Checked::to_wat

fn Checked::to_wat(self : Checked, trivia? :
Context
) -> String raise CompileError

Print in the WebAssembly text format.

The same lowered module the binary form comes from, printed rather than encoded, so the two cannot drift. trivia carries the source comments; they were written against Wax source and come out as WAT comments, with the same text and different delimiters.

#
Session

One compilation.

A session is single-use per module. The type store it carries is filled by checking, so checking a second module through the same session would build on the first module's type section.

#
Session::check

Type-check a module.

This ALWAYS returns a Checked, even for a module it rejected, because whether a run is rejected is not decided here: a warning is hidden, shown or promoted to an error by a @warning.Policy the caller owns. Ask reports for the diagnostics under that policy and rejected whether they stop the compilation, and only then lower.

warn_unused turns on the lints that report what a module declares and never uses. It is off by default because a conversion reports what stops it producing a module and a style warning does not -- the reference draws the same line, and wax f.wax -f wasm is silent on a module wax check comments on.

#
Session::new

fn Session::new(features? :
Set
, source? : String) -> Session

Start a compilation.

source is the module's text, used only to render snippets in diagnostics. A generator that has no text to point at leaves it out; the diagnostics then carry their locations and their messages and no excerpt.

#
Session::reports

What the compilation reported, under policy.

Without a policy this is the raw collection, warnings and all. With one, a hidden warning is dropped and a promoted one comes back with severity Error -- which is what makes -W name=error mean something, and why a lint that is off by default costs nothing to have implemented.

#
apply_policy

Resolve every named warning in collected against policy.

The collector buffers diagnostics RAW: the policy belongs to whoever finally re-reports them. Order is preserved, hidden warnings are dropped, and a warning promoted to an error comes back with its severity replaced rather than duplicated.

#
rejected

fn rejected(diagnostics : Array[
Diagnostic
]) -> Bool

Whether any of these diagnostics rejects the module.

Apply the policy first: a warning promoted to an error rejects, and one hidden by the policy does not.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io