Semantic Diff

#9482 Warn when other modules can't inline an @inline function

1 commit

9f3bc63dc4f7c4af0a13c623f7aa767cbd691266..pr-9482

ac21673cb · cknitt + Claude · Nov 29, 2026, 09:08 UTC

Warn when other modules can't inline an @inline function

Why

An exported @inline function stores its body for other modules only when it can: it must be closed, not async, without a directive, and must not call a relative-path external. Otherwise other modules called it, and nothing said so. Warning 113, on by default, now names the reason. It is a warning, not an error, since the function is still inlined in its own module.

addedDiagnostic exported @inline function that isn't stored

let rec helper = x => x > 10 ? x : helper(x + 1)@inline let usesHelper = x => helper(x) + 1@inline let asyncOne = async x => x
diagnostic
Before
After
none Warning number 113 This @inline function is inlined only in this module, not in modules that use it: it uses helper, a value of this module. Warning number 113 This @inline function is inlined only in this module, not in modules that use it: it is async.

Review

  • The warning is reported while the .cmj is built, after type checking. Do -warn-error +113, @warning("-113") and @warnerror("+113") still apply? Yes. The check for fatal warnings now runs after the .cmj is built, and the type checker records the warning state of each @inline value binding, whose @inline may be on the binding or on its function (let f = {@inline x => …}), and of each @inline module binding, whose @inline may be below a module type constraint. Other bindings aren't recorded, which keeps the cost away from the many bindings without @inline. The state holds the binding's @warning and @warnerror, those on its expression and a @@warning above it, under the binding's identifier (Inline_not_stored). Warning 113 is reported in that state, so a silenced value in a nested module doesn't silence another of the same name.
  • Does it fire for functions an interface hides? No. Only exported values are considered, so an @inline helper the .resi leaves out is inlined in its module without a warning. Functions in nested modules and @inline let rec are not covered either.