Laurel Language Designer Guide

11.16. Exception inference🔗

An exception may escape to callers only through a declared throws; one that would escape a procedure without it is asserted not to happen. So a frontend that wants an unchecked exception of Python or JavaScript — or Java — to propagate must currently declare it. Doing that everywhere would give nearly every procedure a throws clause, and every call site would pay to propagate and unwrap a result that almost never carries an exception.

The planned refinement is to infer a procedure's throwable types from its body: a bottom-up analysis over the call graph combining the types a procedure throws directly, the types its callees may throw, and the types it catches locally. A frontend would then declare only what it wants to pin as part of a signature, and let Laurel supply the rest.