Anton Kochkov
Anton Kochkov

Reputation: 1287

How to find all exception-causing functions in OCaml sources

It is widely known that a huge chunk of standard OCaml functions and a lot of common stdlib and 3rd party libraries are often contain functions that can throw exceptions. It can be very tricky to handle, especially if most of the program is written in a functional way. Are there any ways or tools to list/catch all the functions that throw exceptions by auditing the sources?

Upvotes: 4

Views: 173

Answers (2)

Virgile
Virgile

Reputation: 10158

There has been an attempt to build a static analyzer for exceptions, located at https://github.com/OCamlPro/ocp-analyzer. However, last time I checked it crashed even on very simple programs and that the repository consists in a single commit, I'd say that it might be useful only as a starting point for writing a proper analyzer.

Upvotes: 2

Louis Roché
Louis Roché

Reputation: 896

Best solution I know is to use ocp-grep:

ocp-grep Pervasives.raise

Upvotes: 3

Related Questions