Skip to main content

W0076 - Invalid dialyzer attribute

Example

-module(main).

-dialyzer(no_retrn).
%% ^^^^^^^^^ 💡 error: W0076: invalid dialyzer option 'no_retrn', did you mean 'no_return'?

-dialyzer({nowarn_function, nonexistent/0}).
%% ^^^^^^^^^^^^^ error: W0076: function nonexistent/0 is not defined in this module

Explanation

The -dialyzer() attribute controls Dialyzer warning suppression and enablement per module or per function. This diagnostic validates the contents of the attribute, checking for three types of issues:

  1. Invalid dialyzer option — an atom that is not a recognized Dialyzer flag (e.g., n0warn_functiion). If a close match exists, a suggestion is offered.

  2. Non-existent function — a function reference (Name/Arity) that does not correspond to any function defined in the module.

  3. Malformed attribute — the attribute value does not match any valid form (not an atom, not a valid tuple, not a list of valid items).

Valid forms of the -dialyzer() attribute include:

  • -dialyzer(Option). — a single option atom applied to the whole module
  • -dialyzer({Option, FunRef}). — an option applied to a specific function
  • -dialyzer({Option, [FunRef, ...]}). — an option applied to multiple functions
  • -dialyzer([Item, ...]). — a list of options or option/function-reference tuples

Where FunRef is FunctionName/Arity.