Wax_utils.DiagnosticSourceval run :
color:Colors.flag ->
palette:Colors.theme ->
source:string option ->
?related:label list ->
?exit:bool ->
?output:Format.formatter ->
?policy:Warning.policy ->
(context -> 'a) ->
'arun ~color ~palette ~source ?related ?exit ?output ?policy f runs the diagnostic context f, a rendering context that prints its diagnostics. color and palette are both mandatory: a rendering context must decide up front whether to emit ANSI colour, and which source palette to colour AST fragments embedded in messages with — so a caller cannot silently fall back to a default. Pass Colors.wat_theme for a checker whose diagnostics embed WebAssembly-text types (e.g. Wax_wasm.Validation) and Colors.wax_theme for one embedding Wax types, so they match that language's source colouring. (Contrast collector, which renders nothing and so takes neither.) source is the source code for the diagnostics (if available). policy sets the level — hidden, displayed, or promoted to an error — of each named warning reported with report's warning argument; it defaults to the policy installed by set_policy.
source context is the source code the context was created with (via run's ~source), if any. Byte offsets in a diagnostic's location (pos_cnum) index into this string; used by lints that need to inspect the original text, e.g. to tell whether a subexpression was parenthesized.
set_policy policy installs policy as the default for every context created afterwards (those that do not pass an explicit ?policy). Intended to be called once, from the command line.
set_format fmt selects how diagnostics are rendered (default Human). With Json, every diagnostic — errors, warnings, and syntax errors — is written to stderr as one JSON object per line. Intended to be called once, from the command line.
val report :
context ->
location:Ast.location ->
severity:severity ->
?warning:Warning.t ->
?universal:bool ->
?hint:Message.t ->
?related:label list ->
message:Message.t ->
unit ->
unitreport context ~location ~severity ?warning ?universal ?hint ?related ~message () reports a diagnostic. warning names the warning so the context's policy can decide its level (hide it, display it, or promote it to an error); it is meaningful only with ~severity:Warning and is ignored for errors. universal (default false) marks a diagnostic that is meaningful only when it holds in every reachable configuration; during path-sensitive exploration (see Cond_explore.check_all) such a diagnostic is reported only if it arises under all assumptions, not just some. The unused-local warning is universal: a local used in one conditional branch is not "unused" merely because another configuration prunes that branch.
A collector context accumulates reported errors instead of printing them, so they can be inspected and re-reported. Used for path-sensitive validation, where the same code is validated under several assumptions.
A context that buffers reported errors without printing or exiting. It never renders diagnostics, so it needs none of run's rendering parameters (color, output); pass ?source only when a lint reads the original text via source while reporting against this context. When parent is given (the collector checks part of a larger run — e.g. one configuration of a path-sensitive check), it inherits the parent's error-recovery mode (see set_recovery) so cascade suppression carries into it.
Put context into (or out of) error-recovery mode. In recovery mode a consumer that type-checks a best-effort AST recovered past syntax errors (see Wax_wasm.Parsing's parse_recover) has told the checker that name resolution is unreliable — content dropped at a sync boundary leaves its bindings absent — so "not bound" diagnostics are suppressed as likely cascades while real type errors still surface. Off by default.
Whether context is in error-recovery mode (see set_recovery).
A collected diagnostic.
collected context returns the errors accumulated in context (without clearing or printing them).
A theme for diagnostic output.
val output_error_with_source :
?output:Format.formatter ->
theme:theme ->
source:string ->
location:Ast.location ->
severity:severity ->
?hint:Message.t ->
?related:label list ->
Message.t ->
unitoutput_error_with_source ?output ~theme ~source ~location ~severity ?hint ?related message prints an error message with a source code snippet.
get_theme ?color ?palette () returns the diagnostic theme. palette (default Colors.wax_theme) is the source palette for AST fragments embedded in message bodies.