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@inlinevalue binding, whose@inlinemay be on the binding or on its function (let f = {@inline x => …}), and of each@inlinemodule binding, whose@inlinemay 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@warningand@warnerror, those on its expression and a@@warningabove 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
@inlinehelper the.resileaves out is inlined in its module without a warning. Functions in nested modules and@inline let recare not covered either.