Ast_invariants(3)
β¨ Ast_invariants β¨
okay so bestie, this is a page from the OCaml library manual, and honestly? it's a little niche but it's giving compiler internals realness π so let's get into it.
π¦ NAME π¦
Ast_invariants β literally just: Check AST invariants. that's the whole vibe check, no cap.
π Module π
the module is called Ast_invariants, bestie. say it with me. πΈ
π Documentation π
so the module itself is Module Ast_invariants and its signature is : sig end β yeah, it's an anonymous-ish sig situation, that's just how OCamldoc prints it, don't come for me π
and what does it do? Check AST invariants. icon behaviour, truly. π
β οΈ Warning: this module is unstable and it's part of Compiler_libs. so like, use it but know it might shift under you, ngl. unstable means unstable, fr fr.
π the values π
val structure : Parsetree.structure -> unitβ takes aParsetree.structureand gives you backunit. that's it. that's the whole function. slay. β¨val signature : Parsetree.signature -> unitβ same energy, but for aParsetree.signatureβunit. π«Άval check_loc_ghost : (Ast_iterator.iterator -> Ast_iterator.iterator -> 'a -> unit) -> 'a -> source_contents:string -> unitβ okay this one's the main character π. it checks the invariant ofLocation.t'sloc_ghostfield β the ones that are stated inlocation.mli. (yes,location.mliis the source of truth here, go read it, iykyk π)
you can run this with -dparsetree-loc-ghost-invariants, which is used slightly in the testsuite β but honestly it should be used more, so we can find more of the places where the invariant is broken. like, more coverage bestie, we're begging π₯Ί
lowkey a reminder thatcheck_loc_ghosttakes a function of twoAst_iterator.iteratorargs, then'a, and a labelledsource_contents:stringβ keep those exactly as written, they're load-bearing π
and that's the page!! πΈπ¦π
sign-off szn: this lil doc was made with OCamldoc, dated 2026-06-22, and it's page Ast_invariants(3) of the OCaml library manual. mwah, go check those invariants πβ¨
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms