package wax-lib

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wax_lang.Typing_lintSource

Pure AST analysis helpers and the source-walking lint checks. The analysis primitives (value-effect classification, hole counting, the per-function collection passes) are shared with the type checker; the lint checks (constant conditions, shift/division/conversion traps, tautologies, redundant arithmetic, eager ?:, operator precedence) run once over the source AST and emit warnings. The warning-emitting Error submodule is internal.

Sourceval is_pure_unary_method : string -> bool
Sourceval is_pure_binary_method : string -> bool

Whether a no-/one-argument numeric instruction method (x.abs(), x.min(y)) is pure and total.

Sourceval cast_is_total : Ast.casttype -> bool

Whether a cast never traps, so discarding its result is pointless.

Sourceval is_effectless : 'a Ast.instr -> bool

Whether evaluating an expression has no side effect and cannot trap.

Sourceval collect_assigned_locals : Typing_env.StringSet.t -> 'a Ast.instr -> Typing_env.StringSet.t

Accumulate the local names assigned (Set/Tee targets) anywhere in an instruction.

Sourceval collect_labels : Ast.label list -> 'a Ast.instr -> Ast.label list

Accumulate the block labels declared anywhere in an instruction.

Sourceval find_eager_hazard : 'a Ast.instr -> 'a option

The location of a trapping/effectful operation on the eagerly-evaluated spine of a ?: branch, or None if the branch is pure.

Sourceval int_literal_value : string -> int64 option
Sourceval int_operand_value : 'a Ast.instr -> int64 option
Sourceval int_operand_value_is_zero : 'a Ast.instr -> bool

Constant-integer-operand parsing/matching for the lints. The operand forms look through a leading sign, matching how Wax_conversion.To_wasm folds it into the emitted iNN.const.

Flag a shift whose constant count is at least the operand's bit width. Deferred until the result cell's width is pinned.

Sourceval flush_deferred_lints : Typing_env.module_context -> unit

Run and clear the lints deferred until their result cells were pinned.

Flag an integer / or % by a constant zero (always traps).

Sourceval float_literal_value : string -> float option
Sourceval round_to_f32 : float -> float
Sourceval float_operand_value : 'a Ast.instr -> float option
Sourceval float_conversion_traps : [< `I32 | `I64 ] -> Ast.signage -> float -> bool

Constant-float-operand parsing and the trapping-conversion predicate for lint_conversion.

Sourceval lint_conversion : Typing_env.module_context -> location:Ast.location -> Ast.casttype -> 'a Ast.instr -> unit

Flag a strict float-to-integer conversion of a constant out of range.

Sourceval identical_operands : 'a Ast.instr -> 'b Ast.instr -> bool

Whether two operands are the same pure read (a local/global get).

Flag a comparison whose result is constant regardless of its operand.

Flag an arithmetic operation with no effect or a constant result (off by default).

As lint_redundant for a unary operation: -e lowers to 0 - e, so a zero operand is the x - 0 identity the Wasm validator reports on the lowered form.

Sourceval lint_condition : Typing_env.module_context -> ?is_while:bool -> Ast.location Ast.instr -> unit

Flag a branch/loop/select condition that is a constant literal.

Sourceval lint_eager_select : Typing_env.module_context -> select:Ast.location -> Ast.location Ast.instr -> unit

Report an eager-evaluation hazard in a ?: branch.

Sourceval binop_kind_name : [< `Arith | `Bitwise | `Comparison | `Shift ] -> string

Human-readable name of a binary operator's precedence class.

Sourceval operand_parenthesized : Typing_env.module_context -> op:(Ast.binop, Ast.location) Ast.annotated -> side:[< `Left | `Right ] -> Ast.location Ast.instr -> bool

Whether a binary operator's operand was written parenthesized (from the source text).

Flag a confusing precedence mix written without disambiguating parentheses.

Walk the source AST and report the purely-syntactic lints (constant conditions, eager ?:, precedence, redundant self-assignment, a pointless drop). The orchestrator that dispatches to the checks above.