Ast\_invariants(3) OCaml library Ast\_invariants(3)

# [NAME](#NAME)

Ast\_invariants - Check AST invariants

# [Module](#Module)

Module Ast\_invariants

# [Documentation](#Documentation)

Module **Ast\_invariants**  
: **sig end**

Check AST invariants

Warning: this module is unstable and part of **Compiler\_libs** .

*val structure* : **Parsetree.structure -&gt; unit**

*val signature* : **Parsetree.signature -&gt; unit**

*val check\_loc\_ghost* : **(Ast\_iterator.iterator -&gt; Ast\_iterator.iterator -&gt; 'a -&gt; unit) -&gt;** **'a -&gt; source\_contents:string -&gt; unit**

Checks the invariant of Location.t's loc\_ghost field, that are stated in location.mli. This can be run with -dparsetree-loc-ghost-invariants, which is used slightly in the testsuite, but should be used more to find more of the places where the invariant is broken.

2026-10-23 OCamldoc

---

Document: Ast_invariants(3o) from ocaml 5.5.2-r0 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
