Skip to main content

W0016 - Deprecated Function

Error​

main() ->
b:not_ok_to_use().
%% ^^^^^^^^^^^^^^^^^ 💡 warning: Function 'not_ok_to_use/0' is deprecated.

Explanation​

The warning message indicates that the invoked function is deprecated, which means it is no longer recommended for use.

To fix the problem you should investigate why the function is deprecated and whether there is an alternative function that can be used instead. You may need to refer to documentation to determine the best course of action.

A function is usually deprecated via the -deprecated attribute. This analysis is very similar to the deprecated_function_calls analysis performed by the XRef cross-reference tool.

There is currently no support for the -ignore_xref attribute used by rebar3 to silent specific instances of this diagnostic. Instead, the standard elp:ignore mechanism should be used.

Like the Erlang compiler, the diagnostic honours the following compiler options when given via a -compile attribute in the calling module:

  • nowarn_deprecated_function suppresses the diagnostic for all calls in the module.
  • {nowarn_deprecated_function, MFAs}, where MFAs is a {Module, Name, Arity} tuple or a list of such tuples, suppresses it for calls to the listed functions only.
  • warn_deprecated_function re-enables the diagnostic. When both nowarn_deprecated_function and warn_deprecated_function are given, the last one wins. Functions listed in {nowarn_deprecated_function, MFAs} stay suppressed.
-compile({nowarn_deprecated_function, [{b, not_ok_to_use, 0}]}).

Such module-level suppressions are themselves reported by W0054.