DIALYZER(1) General Commands Manual DIALYZER(1)

dialyzer - Dialyzer is a DIscrepancy AnaLYZer for ERlang programs.

Dialyzer is a static analysis tool that identifies software discrepancies, such as definite type errors, code that is unreachable because of programming errors, and unnecessary tests in single Erlang modules or an entire codebase.

Dialyzer starts its analysis from either debug-compiled BEAM code or from Erlang source code. The file and line number of a discrepancy is reported along with an indication of the nature of the discrepancy. Dialyzer bases its analysis on the concept of success typings, ensuring sound warnings without false positives.

This section provides a brief description of the options available when running Dialyzer from the command line. The same information can be obtained by writing the following in a shell:

dialyzer --help

Exit status of the command-line version:

Usage:

dialyzer [--add_to_plt] [--apps applications] [--build_plt]
         [--check_plt] [-Ddefine]* [-Dname]* [--dump_callgraph file]
         [--error_location flag] [files_or_dirs] [--fullpath]
         [--get_warnings] [--help] [-I include_dir]*
         [--incremental] [--metrics_file] [--no_check_plt] [--no_indentation]
         [--no_spec] [-o outfile] [--output_plt file] [-pa dir]* [--plt plt]
         [--plt_info] [--plts plt*] [--quiet] [-r dirs] [--raw]
         [--remove_from_plt] [--shell] [--src] [--statistics] [--verbose]
         [--version] [--warning_apps applications] [-Wwarn]*
Note
* denotes that multiple occurrences of the option are possible.

Options of the command-line version:

dialyzer --build_plt --apps erts kernel stdlib mnesia ...
to refer conveniently to library applications corresponding to the Erlang/OTP installation. This option can also be used during analysis to refer to Erlang/OTP applications. File or directory names can also be included, as in:
dialyzer --apps inets ssl ./ebin ../other_lib/ebin/my_module.beam

dialyzer --build_plt --output_plt plt_1 files_to_include
...
dialyzer --build_plt --output_plt plt_n files_to_include
They can then be used in either of the following ways:
dialyzer files_to_analyze --plts plt_1 ... plt_n
or
dialyzer --plts plt_1 ... plt_n -- files_to_analyze
Notice the -- delimiter in the second case.
Note
** the syntax of defines and includes is the same as that used by erlc.

Warning options:

The following options are also available, but their use is not recommended (they are mostly for Dialyzer developers and internal debugging):

Note
*** denotes options that turn on warnings rather than turning them off.

The following options are not strictly needed as they specify the default. They are primarily intended to be used with the -dialyzer attribute. For an example see section Requesting or Suppressing Warnings in Source Files %60m:dialyzer#suppression%60.

Dialyzer can be used directly from Erlang. The options are similar to the ones given from the command line. See section Using Dialyzer from the Command Line.

The (host operating system) environment variable ERL_COMPILER_OPTIONS can be used to give default Dialyzer options. Its value must be a valid Erlang term. If the value is a list, it is used as is. If it is not a list, it is put into a list.

The list is appended to any options given to run/1 or on the command line.

The list can be retrieved with compile:env_compiler_options/0.

Currently the only option used is the error_location option.

Dialyzer configuration file:

Dialyzer's configuration file may also be used to augment the default options and those given directly to the Dialyzer command. It is commonly used to avoid repeating options which would otherwise need to be given explicitly to Dialyzer on every invocation.

The location of the configuration file can be set via the DIALYZER_CONFIG environment variable, and defaults to within the user_config from filename:basedir/3.

An example configuration file's contents might be:

      {incremental,
        {default_apps,[stdlib,kernel,erts]},
        {default_warning_apps,[stdlib]}
      }.
      {warnings, [no_improper_lists]}.
      {add_pathsa,["/users/samwise/potatoes/ebin"]}.
      {add_pathsz,["/users/smeagol/fish/ebin"]}.

Attribute -dialyzer() can be used for turning off warnings in a module by specifying functions or warning options. For example, to turn off all warnings for the function f/0, include the following line:

-dialyzer({nowarn_function, f/0}).

To turn off warnings for improper lists, add the following line to the source file:

-dialyzer(no_improper_lists).

Attribute -dialyzer() is allowed after function declarations. Lists of warning options or functions are allowed:

-dialyzer([{nowarn_function, [f/0]}, no_improper_lists]).

Warning options can be restricted to functions:

-dialyzer({no_improper_lists, g/0}).
-dialyzer({[no_return, no_match], [g/0, h/0]}).

The warning option for underspecified functions, -Wunderspecs, can result in useful warnings, but often functions with specifications that are strictly more allowing than the success typing cannot easily be modified to be less allowing. To turn off the warning for underspecified function f/0, include the following line:

-dialyzer({no_underspecs, f/0}).

For help on the warning options, use dialyzer -Whelp. The options are also enumerated, see type t:warn_option/0.

Attribute -dialyzer() can also be used for turning on warnings. For example, if a module has been fixed regarding unmatched returns, adding the following line can help in assuring that no new unmatched return warnings are introduced:

-dialyzer(unmatched_returns).

January 2025