Semantic Diff

#9481 Count the exception a try handler binds as bound

2 commits

b55d092372e48a917e03f85bb64b811c59854f6a..pr-9481

246352491 · cknitt + Claude · Nov 29, 2026, 08:08 UTC

Count the exception a try handler binds as bound

Why

Lam_closure did not add the variable a try … catch handler binds to the bound variables, so inside the handler it counted as free, and every function containing a handler looked as if it captured a variable. Such functions were never closed, so an @inline function with a try … catch was never stored for other modules and always called. Inlined copies get fresh names for that variable, since Lam_bounded_vars renames it like any other binder.

modifiedJS a module using an @inline function with try … catch

// Inline_export.res@inlinelet catchMessage = f =>  try f() catch {  | JsExn(e) => JsExn.message(e)  | _ => None  } // inline_export_test.reslet fromCatch = Inline_export.catchMessage(() => JsError.throwWithMessage("boom"))
js
Before
After
let fromCatch = Inline_export.catchMessage(() => Stdlib_JsError.throwWithMessage("boom")); let fromCatch; try { fromCatch = Stdlib_JsError.throwWithMessage("boom");} catch (raw_e) { let e = Primitive_exceptions.internalToException(raw_e); fromCatch = e.RE_EXN_ID === "JsExn" ? Stdlib_JsExn.message(e._1) : undefined;}

Review

  • Does inlining within a module change? Not in the repository's tests: the runtime, Belt and every test output other than this one are the same.
a717669c3 · cknitt + Claude · Nov 29, 2026, 08:10 UTC

Add the inlined catchMessage output and the changelog entry

The test output and the changelog fragment belonging to the previous commit, which they were left out of.