package ppx_unreachable

  1. Overview
  2. Docs
A tool for denoting unreachable control flow paths

Install

Dune Dependency

Authors

Maintainers

Sources

ppx_unreachable-1.1.tbz
sha256=0979883ca31f4f1b8528769d779f25f149c2ccb0b039f7cc0bfe0d40654b1672
sha512=2f8d1cd3fa52f5ea13510d54aa957ab99b5097e8afec8888ceda2e827047218f5bb952e065db7c870f673a068db91ec9e2e6dd652a561ad46b73cfe23fe42128

Description

A PPX that denotes unreachable code and prints descriptive errors when the code is reached

Published: 08 Jun 2025

README

ppx_unreachable

A PPX that denotes unreachable code and prints descriptive errors when the code is reached

Install

opam install ppx_unreachable

Example

let test_map x y =
  match List.map (fun x -> 2 * x) [x; y] with
  | [x'; y'] -> "this branch will always be taken"
  | _ -> [%unreachable]

(* Bad example *)
let test_if x =
  if x > 10 then
    "big"
  else if x < 0 then
    "small"
  else
    [%unreachable]

let test_if_msg x =
  if x > 10 then
    "big"
  else if x < 0 then
    "small"
  else
    [%unreachable_msg "0 <= x <= 10"]

let () = test_if 5 (* unreachable branch hit - test.ml:13 *)
let () = test_if_msg 5 (* unreachable branch hit - 0 <= x <= 10 *)

Dependencies (3)

  1. ppxlib >= "0.36"
  2. dune >= "3.9"
  3. ocaml

Dev Dependencies (1)

  1. odoc with-doc

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.