1dialyzer(3)                Erlang Module Definition                dialyzer(3)
2
3
4

NAME

6       dialyzer - Dialyzer, a DIscrepancy AnaLYZer for ERlang programs.
7
8

DESCRIPTION

10       Dialyzer  is a static analysis tool that identifies software discrepan‐
11       cies, such as definite type  errors,  code  that  has  become  dead  or
12       unreachable  because  of  programming  error, and unnecessary tests, in
13       single Erlang modules or entire (sets of) applications.
14
15       Dialyzer starts its analysis from either debug-compiled  BEAM  bytecode
16       or  from  Erlang source code. The file and line number of a discrepancy
17       is reported along with an indication of what the discrepancy is  about.
18       Dialyzer  bases  its  analysis on the concept of success typings, which
19       allows for sound warnings (no false positives).
20

USING DIALYZER FROM THE COMMAND LINE

22       Dialyzer has a command-line version for  automated  use.  This  section
23       provides  a  brief description of the options. The same information can
24       be obtained by writing the following in a shell:
25
26       dialyzer --help
27
28       For more details about the operation of Dialyzer,  see  section   Using
29       Dialyzer from the GUI in the User's Guide.
30
31       Exit status of the command-line version:
32
33         0:
34           No  problems  were  found  during the analysis and no warnings were
35           emitted.
36
37         1:
38           Problems were found during the analysis.
39
40         2:
41           No problems were found during the analysis, but warnings were emit‐
42           ted.
43
44       Usage:
45
46       dialyzer [--add_to_plt] [--apps applications] [--build_plt]
47                [--check_plt] [-Ddefine]* [-Dname] [--dump_callgraph file]
48                [files_or_dirs] [--fullpath] [--get_warnings] [--gui] [--help]
49                [-I include_dir]* [--no_check_plt] [--no_native]
50                [--no_native_cache] [-o outfile] [--output_plt file] [-pa dir]*
51                [--plt plt] [--plt_info] [--plts plt*] [--quiet] [-r dirs]
52                [--raw] [--remove_from_plt] [--shell] [--src] [--statistics]
53                [--verbose] [--version] [-Wwarn]*
54
55   Note:
56       * denotes that multiple occurrences of the option are possible.
57
58
59       Options:
60
61         --add_to_plt:
62           The PLT is extended to also include the files specified with -c and
63           -r. Use --plt to specify which PLT to start from, and  --output_plt
64           to  specify where to put the PLT. Notice that the analysis possibly
65           can include files from the PLT if they depend  on  the  new  files.
66           This option only works for BEAM files.
67
68         --apps applications:
69           This  option  is typically used when building or modifying a PLT as
70           in:
71
72         dialyzer --build_plt --apps erts kernel stdlib mnesia ...
73
74           to refer conveniently to library applications corresponding to  the
75           Erlang/OTP  installation.  However,  this option is general and can
76           also be used during analysis to refer to  Erlang/OTP  applications.
77           File or directory names can also be included, as in:
78
79         dialyzer --apps inets ssl ./ebin ../other_lib/ebin/my_module.beam
80
81         --build_plt:
82           The  analysis  starts  from an empty PLT and creates a new one from
83           the files specified with -c and -r. This option only works for BEAM
84           files.  To  override  the default PLT location, use --plt or --out‐
85           put_plt.
86
87         --check_plt:
88           Check the PLT for consistency and rebuild it if it  is  not  up-to-
89           date.
90
91         -Dname (or -Dname=value):
92           When analyzing from source, pass the define to Dialyzer. (**)
93
94         --dump_callgraph file:
95           Dump  the call graph into the specified file whose format is deter‐
96           mined by the filename extension.  Supported  extensions  are:  raw,
97           dot,  and  ps.  If  something  else  is used as filename extension,
98           default format .raw is used.
99
100         files_or_dirs (for backward compatibility also as -c files_or_dirs):
101           Use Dialyzer from the command line to detect defects in the  speci‐
102           fied files or directories containing .erl or .beam files, depending
103           on the type of the analysis.
104
105         --fullpath:
106           Display the full path names of files for which warnings  are  emit‐
107           ted.
108
109         --get_warnings:
110           Make  Dialyzer  emit warnings even when manipulating the PLT. Warn‐
111           ings are only emitted for files that are analyzed.
112
113         --gui:
114           Use the GUI.
115
116         --help (or -h):
117           Print this message and exit.
118
119         -I include_dir:
120           When analyzing from source, pass the include_dir to Dialyzer. (**)
121
122         --no_check_plt:
123           Skip the PLT check when running Dialyzer. This is useful when work‐
124           ing with installed PLTs that never change.
125
126         --no_native (or -nn):
127           Bypass  the native code compilation of some key files that Dialyzer
128           heuristically performs when dialyzing many files. This  avoids  the
129           compilation time, but can result in (much) longer analysis time.
130
131         --no_native_cache:
132           By  default,  Dialyzer  caches the results of native compilation in
133           directory               $XDG_CACHE_HOME/erlang/dialyzer_hipe_cache.
134           XDG_CACHE_HOME defaults to $HOME/.cache. Use this option to disable
135           caching.
136
137         -o outfile (or --output outfile):
138           When using Dialyzer  from  the  command  line,  send  the  analysis
139           results to the specified outfile rather than to stdout.
140
141         --output_plt file:
142           Store the PLT at the specified file after building it.
143
144         -pa dir:
145           Include  dir  in the path for Erlang. This is useful when analyzing
146           files that have -include_lib() directives.
147
148         --plt plt:
149           Use the specified PLT as the initial PLT. If the PLT was built dur‐
150           ing setup, the files are checked for consistency.
151
152         --plt_info:
153           Make  Dialyzer  print  information about the PLT and then quit. The
154           PLT can be specified with --plt(s).
155
156         --plts plt*:
157           Merge the specified PLTs to create the initial PLT.  This  requires
158           that the PLTs are disjoint (that is, do not have any module appear‐
159           ing in more than one PLT). The PLTs are created in the usual way:
160
161         dialyzer --build_plt --output_plt plt_1 files_to_include
162         dialyzer --build_plt --output_plt plt_n files_to_include
163
164           They can then be used in either of the following ways:
165
166         dialyzer files_to_analyze --plts plt_1 ... plt_n
167
168           or
169
170         dialyzer --plts plt_1 ... plt_n -- files_to_analyze
171
172           Notice the -- delimiter in the second case.
173
174         --quiet (or -q):
175           Make Dialyzer a bit more quiet.
176
177         -r dirs:
178           Same as files_or_dirs, but the specified directories  are  searched
179           recursively  for  subdirectories  containing .erl or .beam files in
180           them, depending on the type of analysis.
181
182         --raw:
183           When using Dialyzer from the command line, output the raw  analysis
184           results  (Erlang  terms)  instead  of the formatted result. The raw
185           format is easier to post-process (for example, to  filter  warnings
186           or to output HTML pages).
187
188         --remove_from_plt:
189           The  information from the files specified with -c and -r is removed
190           from the PLT. Notice that  this  can  cause  a  reanalysis  of  the
191           remaining dependent files.
192
193         --shell:
194           Do not disable the Erlang shell while running the GUI.
195
196         --src:
197           Override  the  default, which is to analyze BEAM files, and analyze
198           starting from Erlang source code instead.
199
200         --statistics:
201           Print information about the progress of execution (analysis phases,
202           time spent in each, and size of the relative input).
203
204         --verbose:
205           Make Dialyzer a bit more verbose.
206
207         --version (or -v):
208           Print the Dialyzer version and some more information and exit.
209
210         -Wwarn:
211           A  family  of  options  that selectively turn on/off warnings. (For
212           help on the names of warnings, use dialyzer  -Whelp.)  Notice  that
213           the  options  can  also be specified in the file with a -dialyzer()
214           attribute. For details, see section Requesting or Suppressing Warn‐
215           ings in Source Files.
216
217   Note:
218       **  options  -D  and -I work both from the command line and in the Dia‐
219       lyzer GUI; the syntax of defines and includes is the same as that  used
220       by erlc(1).
221
222
223       Warning options:
224
225         -Werror_handling (***):
226           Include warnings for functions that only return by an exception.
227
228         -Wno_behaviours:
229           Suppress warnings about behavior callbacks that drift from the pub‐
230           lished recommended interfaces.
231
232         -Wno_contracts:
233           Suppress warnings about invalid contracts.
234
235         -Wno_fail_call:
236           Suppress warnings for failing calls.
237
238         -Wno_fun_app:
239           Suppress warnings for fun applications that will fail.
240
241         -Wno_improper_lists:
242           Suppress warnings for construction of improper lists.
243
244         -Wno_match:
245           Suppress warnings for patterns that are unused or cannot match.
246
247         -Wno_missing_calls:
248           Suppress warnings about calls to missing functions.
249
250         -Wno_opaque:
251           Suppress warnings for violations of opacity of data types.
252
253         -Wno_return:
254           Suppress warnings for functions that will never return a value.
255
256         -Wno_undefined_callbacks:
257           Suppress warnings about behaviors that have no -callback attributes
258           for their callbacks.
259
260         -Wno_unused:
261           Suppress warnings for unused functions.
262
263         -Wrace_conditions (***):
264           Include  warnings  for  possible  race  conditions. Notice that the
265           analysis that finds data races performs intra-procedural data  flow
266           analysis  and  can sometimes explode in time. Enable it at your own
267           risk.
268
269         -Wunderspecs (***):
270           Warn about underspecified functions (the specification is  strictly
271           more allowing than the success typing).
272
273         -Wunknown (***):
274           Let warnings about unknown functions and types affect the exit sta‐
275           tus of the command-line version. The default is to ignore  warnings
276           about  unknown  functions  and  types when setting the exit status.
277           When using Dialyzer from Erlang, warnings about  unknown  functions
278           and  types  are  returned; the default is not to return these warn‐
279           ings.
280
281         -Wunmatched_returns (***):
282           Include warnings for function calls that ignore a structured return
283           value or do not match against one of many possible return value(s).
284
285       The  following  options are also available, but their use is not recom‐
286       mended (they are mostly for Dialyzer  developers  and  internal  debug‐
287       ging):
288
289         -Woverspecs (***):
290           Warn  about  overspecified functions (the specification is strictly
291           less allowing than the success typing).
292
293         -Wspecdiffs (***):
294           Warn when the specification is different than the success typing.
295
296   Note:
297       *** denotes options that turn on warnings rather than turning them off.
298
299

USING DIALYZER FROM ERLANG

301       Dialyzer can be used directly from Erlang. Both the GUI  and  the  com‐
302       mand-line  versions  are also available. The options are similar to the
303       ones given from the command line, see section  Using Dialyzer from  the
304       Command Line.
305

REQUESTING OR SUPPRESSING WARNINGS IN SOURCE FILES

307       Attribute  -dialyzer() can be used for turning off warnings in a module
308       by specifying functions or warning options. For example,  to  turn  off
309       all warnings for the function f/0, include the following line:
310
311       -dialyzer({nowarn_function, f/0}).
312
313       To  turn off warnings for improper lists, add the following line to the
314       source file:
315
316       -dialyzer(no_improper_lists).
317
318       Attribute -dialyzer() is allowed after function declarations. Lists  of
319       warning options or functions are allowed:
320
321       -dialyzer([{nowarn_function, [f/0]}, no_improper_lists]).
322
323       Warning options can be restricted to functions:
324
325       -dialyzer({no_improper_lists, g/0}).
326
327       -dialyzer({[no_return, no_match], [g/0, h/0]}).
328
329       For  help  on the warning options, use dialyzer -Whelp. The options are
330       also enumerated, see function gui/1 below (WarnOpts).
331
332   Note:
333       Warning option -Wrace_conditions has  no  effect  when  set  in  source
334       files.
335
336
337       Attribute  -dialyzer()  can  also  be used for turning on warnings. For
338       example, if a module has been fixed regarding unmatched returns, adding
339       the  following  line  can help in assuring that no new unmatched return
340       warnings are introduced:
341
342       -dialyzer(unmatched_returns).
343

EXPORTS

345       format_warning(Msg) -> string()
346
347              Types:
348
349                 Msg = {Tag, Id, msg()}
350                   See run/1.
351
352              Get a string from warnings as returned by run/1.
353
354       gui() -> ok | {error, Msg}
355       gui(OptList) -> ok | {error, Msg}
356
357              Types:
358
359                 OptList
360                   See below.
361
362              Dialyzer GUI version.
363
364              OptList  :: [Option]
365              Option   :: {files,          [Filename :: string()]}
366                        | {files_rec,      [DirName :: string()]}
367                        | {defines,        [{Macro :: atom(), Value :: term()}]}
368                        | {from,           src_code | byte_code}
369                                             %% Defaults to byte_code
370                        | {init_plt,       FileName :: string()}
371                                             %% If changed from default
372                        | {plts,           [FileName :: string()]}
373                                             %% If changed from default
374                        | {include_dirs,   [DirName :: string()]}
375                        | {output_file,    FileName :: string()}
376                        | {output_plt,     FileName :: string()}
377                        | {check_plt,      boolean()},
378                        | {analysis_type,  'succ_typings' |
379                                           'plt_add' |
380                                           'plt_build' |
381                                           'plt_check' |
382                                           'plt_remove'}
383                        | {warnings,       [WarnOpts]}
384                        | {get_warnings,   bool()}
385
386              WarnOpts :: error_handling
387                        | no_behaviours
388                        | no_contracts
389                        | no_fail_call
390                        | no_fun_app
391                        | no_improper_lists
392                        | no_match
393                     | no_missing_calls
394                        | no_opaque
395                     | no_return
396                        | no_undefined_callbacks
397                        | no_unused
398                        | race_conditions
399                        | underspecs
400                        | unknown
401                        | unmatched_returns
402                        | overspecs
403                        | specdiffs
404
405       plt_info(string()) -> {'ok', [{atom(), any()}]} | {'error', atom()}
406
407              Returns information about the specified PLT.
408
409       run(OptList) -> Warnings
410
411              Types:
412
413                 OptList
414                   See gui/0,1.
415                 Warnings
416                   See below.
417
418              Dialyzer command-line version.
419
420              Warnings :: [{Tag, Id, Msg}]
421              Tag      :: 'warn_behaviour'
422                        | 'warn_bin_construction'
423                        | 'warn_callgraph'
424                        | 'warn_contract_not_equal'
425                        | 'warn_contract_range'
426                        | 'warn_contract_subtype'
427                        | 'warn_contract_supertype'
428                        | 'warn_contract_syntax'
429                        | 'warn_contract_types'
430                        | 'warn_failing_call'
431                        | 'warn_fun_app'
432                        | 'warn_matching'
433                        | 'warn_non_proper_list'
434                        | 'warn_not_called'
435                        | 'warn_opaque'
436                        | 'warn_race_condition'
437                        | 'warn_return_no_exit'
438                        | 'warn_return_only_exit'
439                        | 'warn_umatched_return'
440                        | 'warn_undefined_callbacks'
441                        | 'warn_unknown'
442              Id  = {File :: string(), Line :: integer()}
443              Msg = msg() -- Undefined
444
445
446
447Ericsson AB                     dialyzer 3.3.2                     dialyzer(3)
Impressum