package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4361e1324b7754a4c08ab5b505df32061f3ce0cea60443fd0d3699e0fa796b32
sha512=fcc756d2f160ba90a9aa1131f2ab22ed7f45466ccd658c21cf9df6868a6aab0cee7f404719d698a379958802f9820398f2fe0685ecc4dda018ca4f653294e39b
doc/wax-lib.utils/Wax_utils/Warning/index.html
Module Wax_utils.WarningSource
Named, groupable warnings whose reporting level is configurable.
Each diagnostic warning has a stable name (e.g. unused-local) and may belong to one or more groups (e.g. unused). A policy maps each warning to a level — hidden, displayed, or promoted to an error — so the same warning can be silenced, shown, or made fatal depending on the invocation (see the -W command-line option).
type t = | Unused_local(*A local that is declared but never read.
*)| Unused_field(*A module field — a function, global, memory, table, tag, type, or a passive data/element segment — that nothing reachable references. Liveness is reachability from the roots (the exported and start functions, and every reference from a module-level context: an initializer, a segment), so a dead cycle of mutually recursive functions or types is reported, as is anything only dead code references.
*)| Unused_import(*An imported function, global, memory, table, or tag that nothing reachable references — the same analysis as
*)Unused_field.| Unused_label(*A block label that is declared but never branched to.
*)| Unnecessary_mut(*A global declared mutable but never assigned, so it could be declared immutable (Wax
*)const, Wasm withoutmut). Only a module-defined, non-exported global is flagged: an import's mutability is fixed by the linking contract, and an exported mutable global can be assigned by the host.| Shift_overflow(*A shift by a constant count at least as large as the operand's bit width; Wasm masks the count modulo the width, so the shift is almost certainly not what was meant.
*)| Constant_trap(*An operation that always traps on a constant operand: an integer division or remainder by zero, or a trapping float-to-integer conversion of an out-of-range constant.
*)| Tautological_comparison(*A comparison whose result is constant regardless of its variable operand: an unsigned comparison against zero, or a comparison of two identical operands.
*)| Constant_condition(*A branch, loop, or
*)selectcondition that is a constant, so it always (or never) takes the same path.| Unused_result(*The result of a side-effect-free expression is computed and then discarded (e.g.
*)_ = x + 1).| Dead_code(*A statement that can never be reached because it follows an unconditional branch,
*)return, orunreachable.| Cast_always_fails(*A reference cast or test whose operand can never have the target type (the two are unrelated in the type hierarchy), so the cast always traps and the test is always false.
*)| Eager_select(*A trapping or effectful operation (an integer division, a field or element access, a
*)!, a descriptor cast, a call, an assignment, …) appears in a branch of a?:. Since?:compiles to aselect, which evaluates both branches, that operation runs even when the condition selects the other branch.| Precedence(*Two operators whose relative precedence is easy to misremember are mixed without parentheses: a shift (
*)<</>>) with an arithmetic operator (+,-,*, …), or a comparison with a bitwise operator (&,|,^). The code is correct, but a reader (especially one used to C's different table) may misread the grouping.| Redundant_operation(*An operation with no effect on its result: an arithmetic identity (
*)x + 0,x * 1,x << 0, …), an absorbing operand (x * 0,x & 0), an operation on two identical operands (x - x,x ^ x,x & x), a self-assignment (x = x), or a cast to a type the operand already has.| Truncated_coverage(*Path-sensitive validation gave up after too many conditional configurations.
*)| Naming_conflict(*Converting from Wasm, a source name collided with another and was renamed to a fresh one.
*)| Reserved_word_rename(*Converting from Wasm, a source name is a Wax reserved word and was renamed to a fresh one.
*)| Generated_name(*Converting from Wasm, an unnamed but referenced parameter was given a generated name (it cannot be rendered anonymously).
*)| Compound_assignment(*A plain assignment could use the compound form:
*)x = x + ereads back asx += e. Carries a machine-applicable rewrite (Suggestion).| Field_punning(*A struct field initialised from a like-named local/global could use the punning shorthand:
*){x: x}reads back as{x}(Suggestion).| Redundant_annotation(*A
*)lettype annotation the inferred type already makes redundant could be dropped:let x: t = ereads back aslet x = e(Suggestion).| Confusable_unicode(*A string (an export/import name, a string literal, or a data segment) contains a bidirectional control character that can make the source read differently than it runs (a "Trojan Source" character).
*)
Whether the warning flags code that can be removed with no change in behaviour (an unused binding, import, or label, or unreachable code), so an editor can render it faded — LSP's DiagnosticTag.Unnecessary, VS Code's greyed-out dead code.
Levels and policies
set policy name level returns policy updated so that the warning named name (or every warning in the group named name, including the special group "all") has level level. Returns Error msg if name matches no known warning or group. Later calls override earlier ones.
parse_spec s parses a -W argument of the form NAME=LEVEL into its warning/group name and level. LEVEL is one of hidden, warning, or error. Returns Error msg on a malformed spec or unknown level.
The names of the warning groups (excluding the special "all"), for help text.