~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/dialyzer/doc/src/dialyzer.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Erlang Packagers, Sergei Golovan
  • Date: 2006-12-03 17:07:44 UTC
  • mfrom: (2.1.11 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203170744-rghjwupacqlzs6kv
Tags: 1:11.b.2-4
[ Sergei Golovan ]
Fixed erlang-base and erlang-base-hipe prerm scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!doctype comref PUBLIC "-//Stork//DTD comref//EN">
 
2
 
 
3
<!-- 
 
4
 ``The contents of this file are subject to the Erlang Public License,
 
5
 Version 1.1, (the "License"); you may not use this file except in
 
6
 compliance with the License. You should have received a copy of the
 
7
 Erlang Public License along with this software. If not, it can be
 
8
 retrieved via the world wide web at http://www.erlang.org/.
 
9
 
 
10
 Software distributed under the License is distributed on an "AS IS"
 
11
 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
12
 the License for the specific language governing rights and limitations
 
13
 under the License.
 
14
 
 
15
 The Initial Developer of the Original Code is Ericsson Utvecklings AB.
 
16
 Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
 
17
 AB. All Rights Reserved.''
 
18
 
 
19
     $Id$
 
20
-->
 
21
<COMREF>
 
22
  <HEADER>
 
23
    <TITLE>dialyzer</TITLE>
 
24
    <PREPARED>Tobias Lindahl and Kostis Sagonas</PREPARED>
 
25
    <DOCNO></DOCNO>
 
26
    <DATE></DATE>
 
27
    <REV></REV>
 
28
  </HEADER>
 
29
  <COM>dialyzer</COM>
 
30
  <COMSUMMARY>Erlang Dialyzer</COMSUMMARY>
 
31
  <DESCRIPTION>
 
32
<P>This is the command line version for automated use. Below is a
 
33
brief description of the list of its options. The same information can
 
34
be obtained by writing</P>
 
35
 
 
36
<PRE>
 
37
        <INPUT>"dialyzer --help"</INPUT>
 
38
</PRE>
 
39
 
 
40
<P>in a shell. Please refer to the GUI description in the User's Guide, for more details on the operation of Dialyzer.</P>
 
41
 
 
42
<P>The exit status of the command line version is:</P>
 
43
 
 
44
<CODE>
 
45
    0 - No problems were encountered during the analysis and no
 
46
        warnings were emitted.
 
47
    1 - Problems were encountered during the analysis.
 
48
    2 - No problems were encountered, but warnings were emitted.
 
49
 
 
50
 
 
51
 
 
52
Usage: dialyzer [--otp OTP_DIR] [--help] [--version] [--shell]
 
53
                 [-pa dir]* [-plt plt] [-Ddefine]* [-I include_dir]* 
 
54
                 [--output_plt file] [-Wwarn]*  [--src] 
 
55
                 [-c applications] [-r applications] [-o outfile] [-q]
 
56
 
 
57
Options: 
 
58
   -c applications (or --command-line applications)
 
59
       use Dialyzer from the command line (no GUI) to detect defects in the
 
60
       specified applications (directories or .erl or .beam files)
 
61
   -r applications
 
62
       same as -c only that directories are searched recursively for 
 
63
       subdirectories containing .erl or .beam files (depending on the 
 
64
       type of analysis)
 
65
   -o outfile (or --output outfile)
 
66
       when using Dialyzer from the command line, send the analysis
 
67
       results in the specified "outfile" rather than in stdout
 
68
   --src
 
69
       overwrite the default, which is to analyze BEAM bytecode, and
 
70
       analyze starting from Erlang source code instead
 
71
   -Dname (or -Dname=value)
 
72
       when analyzing from source, pass the define to Dialyzer (**)
 
73
   -I include_dir
 
74
       when analyzing from source, pass the include_dir to Dialyzer (**)
 
75
   --output_plt file
 
76
       Store the plt at the specified location after building it.
 
77
   --no_warn_on_inline
 
78
       Suppress warnings when analyzing an inline compiled bytecode file.
 
79
   -plt plt
 
80
       Use the specified plt as the initial plt. If the plt was built 
 
81
       during setup the files will be checked for consistency.
 
82
   -pa dir
 
83
       Include dir in the path for Erlang. Useful when analyzing files
 
84
       that have '-include_lib()' directives.
 
85
   -Wwarn
 
86
       a family of option which selectively turn on/off warnings.
 
87
        (for help on the names of warnings use dialyzer -Whelp)
 
88
   --otp OTP_DIR 
 
89
       overrides the default location of the Erlang/OTP system to use
 
90
   --shell
 
91
       do not disable the Erlang shell while running the GUI
 
92
   --version (or -v)
 
93
       prints the Dialyzer version and some more information and exits
 
94
   --help (or -h)
 
95
       prints this message and exits
 
96
   -q
 
97
       makes Dialyzer a bit more quiet
 
98
</CODE>
 
99
 
 
100
<Note>
 
101
  <P>* denotes that multiple occurrences of these options are possible.</P>
 
102
<P> ** options -D and -I work both from command-line and in the Dialyzer GUI;
 
103
    the syntax of defines and includes is the same as that used by "erlc".</P>
 
104
</NOTE>
 
105
 
 
106
<CODE>
 
107
Warning options:
 
108
  -Wno_return
 
109
     Suppress warnings for functions of no return.
 
110
  -Wno_unused
 
111
     Suppress warnings for unused functions.
 
112
  -Wno_improper_lists
 
113
     Suppress warnings for construction of improper lists.
 
114
  -Wno_tuple_as_fun
 
115
     Suppress warnings for using tuples instead of funs.
 
116
  -Wno_fun_app
 
117
     Suppress warnings for fun applications that will fail.
 
118
  -Wno_match
 
119
     Suppress warnings for pattern matching operations that will never 
 
120
     succeed.
 
121
  -Wno_comp
 
122
     Suppress warnings for term comparisons that will always return false.
 
123
  -Wno_guards
 
124
     Suppress warnings for guards that will always fail.
 
125
  -Wno_unsafe_beam
 
126
     Suppress warnings for unsafe BEAM code produced by an old 
 
127
     BEAM compiler.
 
128
  -Werror_handling ***
 
129
     Include warnings for functions that only return by means of an 
 
130
     exception.
 
131
Note:
 
132
   *** This is the only option that turns on warnings rather than 
 
133
       turning them off.
 
134
</CODE>
 
135
 
 
136
 </DESCRIPTION>
 
137
 
 
138
 
 
139
<SECTION>
 
140
    <TITLE>Identified discrepancies</TITLE>
 
141
<P>The discrepancies currently identified by Dialyzer can be classified
 
142
in the following categories:</P>
 
143
 
 
144
 
 
145
 
 
146
    <P><EM>TYPE ERRORS</EM></P
 
147
    <LIST>
 
148
      <ITEM><P>Match failure</P>
 
149
        <LIST>
 
150
          <ITEM><P>Warnings:</P>
 
151
            <LIST>
 
152
              <ITEM>
 
153
                <P>"The clause matching on X will never match; argument is of type T"</P>
 
154
              </ITEM>
 
155
              <ITEM>
 
156
                <P>"The clause matching on tuple with arity N will never match; "</P>
 
157
              </ITEM>
 
158
              <ITEM>
 
159
                <P>" argument is of type T!"</P>
 
160
              </ITEM>
 
161
            </LIST>
 
162
          </ITEM>
 
163
          <ITEM><P>Description:</P>
 
164
            <LIST>
 
165
              <ITEM>
 
166
                <P>The function or case clause will never match since the calling
 
167
                  argument has a different type than the expected one.
 
168
                  Note that due to pattern-matching compilation the X above may be
 
169
                  an argument enclosed in some structured term (tuple or list).</P>
 
170
              </ITEM>
 
171
            </LIST>
 
172
          </ITEM>
 
173
        </LIST>
 
174
      </ITEM>
 
175
    <ITEM><P>Function call with wrong arguments</P>
 
176
        <LIST>
 
177
          <ITEM><P>Warning:</P>
 
178
            <LIST>
 
179
              <ITEM>
 
180
                <P>"Call to function X with signature S will fail since the arguments are of type T!"</P>
 
181
              </ITEM>
 
182
            </LIST>
 
183
          </ITEM>
 
184
          <ITEM><P>Description:</P>
 
185
            <LIST>
 
186
              <ITEM>
 
187
                <P>The arguments which the function is called with are
 
188
                  not what the function implicitly expects.</P>
 
189
              </ITEM>
 
190
            </LIST>
 
191
          </ITEM>
 
192
        </LIST>
 
193
      <ITEM><P>Closure of wrong type</P>
 
194
        <LIST>
 
195
          <ITEM><P>Warnings:</P>
 
196
            <LIST>
 
197
              <ITEM>
 
198
                <P>"Fun application using type T instead of a fun!"</P>
 
199
              </ITEM>
 
200
              <ITEM>
 
201
                <P>"Trying to use fun with type T with arguments AT"</P>
 
202
              </ITEM>
 
203
            </LIST>
 
204
          </ITEM>
 
205
          <ITEM><P>Description:</P>
 
206
            <LIST>
 
207
              <ITEM>
 
208
                <P>The variable that is used in the fun application is either not 
 
209
                  a closure (fun entry) or a closure with the wrong domain.</P>
 
210
              </ITEM>
 
211
            </LIST>
 
212
          </ITEM>
 
213
        </LIST>
 
214
      </ITEM>
 
215
      <ITEM><P>Improper list construction</P>
 
216
        <LIST>
 
217
          <ITEM><P>Warnings:</P>
 
218
            <LIST>
 
219
              <ITEM>
 
220
                <P>"Cons will produce a non-proper list since its 2nd arg is of type T!"</P>
 
221
              </ITEM>
 
222
              <ITEM>
 
223
                <P>"Call to '++'/2 will produce a non-proper list since its 2nd arg is of type T!"</P>
 
224
              </ITEM>
 
225
            </LIST>
 
226
          </ITEM>
 
227
          <ITEM><P>Description:</P>
 
228
            <LIST>
 
229
              <ITEM>
 
230
                <P>This is a place where an improper list (i.e., a list whose last
 
231
                  element is not the empty list []) is constructed. Strictly, these
 
232
                  are not discrepancies in Erlang, but we strongly recommend that
 
233
                  you fix these; there is ABSOLUTELY NO reason to create improper lists.</P>
 
234
              </ITEM>
 
235
            </LIST>
 
236
          </ITEM>
 
237
        </LIST>
 
238
      </ITEM>
 
239
      <ITEM><P>Function of no return</P>
 
240
        <LIST>
 
241
          <ITEM><P>Warning:</P>
 
242
            <LIST>
 
243
              <ITEM>
 
244
                <P>"Function will never return a proper value!"</P>
 
245
              </ITEM>
 
246
            </LIST>
 
247
          </ITEM>
 
248
          <ITEM><P>Description:</P>
 
249
            <LIST>
 
250
              <ITEM>
 
251
                <P>This is a function that never returns. Strictly speaking, this
 
252
                  is not a function and the code is OK only if this is used as a
 
253
                  point where an exception is thrown when handling an error.</P>
 
254
              </ITEM>
 
255
            </LIST>
 
256
          </ITEM>
 
257
        </LIST>
 
258
      </ITEM>
 
259
    </LIST>
 
260
 
 
261
 
 
262
 
 
263
    <P><EM>REDUNDANT OR UNREACHABLE CODE</EM></P>
 
264
 
 
265
    <LIST>
 
266
      <ITEM>
 
267
        <P>Unreachable case clause</P>
 
268
        <LIST>
 
269
          <ITEM>
 
270
            <P>Warning:</P>
 
271
            <LIST>
 
272
              <ITEM>
 
273
                <P>"Type guard X will always fail since variable is of type T!"</P>
 
274
              </ITEM>
 
275
            </LIST>
 
276
          </ITEM>
 
277
          <ITEM>
 
278
            <P>Description:</P>
 
279
            <LIST>
 
280
              <ITEM>
 
281
                <P>The case clause is redundant since the input argument is of a
 
282
                  different type.</P>
 
283
              </ITEM>
 
284
            </LIST>
 
285
          </ITEM>
 
286
        </LIST>
 
287
      </ITEM>
 
288
      <ITEM>
 
289
        <P>Unreachable function clause</P>
 
290
        <LIST>
 
291
          <ITEM>
 
292
            <P>Warning:</P>
 
293
            <LIST>
 
294
              <ITEM>
 
295
                <P>"The guard X will always fail since the arguments are of type T!"</P>
 
296
              </ITEM>
 
297
            </LIST>
 
298
          </ITEM>
 
299
          <ITEM>
 
300
            <P>Description:</P>
 
301
            <LIST>
 
302
              <ITEM>
 
303
                <P>The clause is made redundant due to one of its guards always failing.</P>
 
304
              </ITEM>
 
305
            </LIST>
 
306
          </ITEM>
 
307
        </LIST>
 
308
      </ITEM>
 
309
      <ITEM>
 
310
        <P>Term comparison failure</P>
 
311
        <LIST>
 
312
          <ITEM>
 
313
            <P>Warnings:</P>
 
314
            <LIST>
 
315
              <ITEM>
 
316
                <P>"=:= between T1 and T2 will always fail!"</P>
 
317
              </ITEM>
 
318
              <ITEM>
 
319
                <P>"=/= between T1 and T2 will always fail!"</P>
 
320
              </ITEM>
 
321
            </LIST>
 
322
          </ITEM>
 
323
          <ITEM>
 
324
            <P>Description:</P>
 
325
            <LIST>
 
326
              <ITEM>
 
327
                <P>The term comparison will always fail making the test always return
 
328
                  'false' or, in a guard context, making the clause redundant.</P>
 
329
              </ITEM>
 
330
            </LIST>
 
331
          </ITEM>
 
332
        </LIST>
 
333
      </ITEM>
 
334
      <ITEM>
 
335
        <P>Unused function</P>
 
336
        <LIST>
 
337
          <ITEM>
 
338
            <P>Warning:</P>
 
339
            <LIST>
 
340
              <ITEM>
 
341
                <P>"Function will never be called!"</P>
 
342
              </ITEM>
 
343
            </LIST>
 
344
          </ITEM>
 
345
          <ITEM>
 
346
            <P>Description:</P>
 
347
            <LIST>
 
348
              <ITEM>
 
349
                <P>The function is unused; no need to have it uncommented in the code.</P>
 
350
              </ITEM>
 
351
            </LIST>
 
352
          </ITEM>
 
353
        </LIST>
 
354
      </ITEM>
 
355
    </LIST>
 
356
 
 
357
 
 
358
 
 
359
    <P><EM>CODE RELICS</EM></P>
 
360
 
 
361
    <LIST>
 
362
      <ITEM>
 
363
        <P>Tuple used as fun</P>
 
364
        <LIST>
 
365
          <ITEM>
 
366
            <P>Warnings:</P>
 
367
            <LIST>
 
368
              <ITEM>
 
369
                <P>"Unsafe use of tuple as a fun in call to X"</P>
 
370
              </ITEM>
 
371
              <ITEM>
 
372
                <P>"Tuple used as fun will fail in native compiled code"</P>
 
373
              </ITEM>
 
374
            </LIST>
 
375
          </ITEM>
 
376
          <ITEM>
 
377
            <P>Description:</P>
 
378
            <LIST>
 
379
              <ITEM>
 
380
                <P>A 2-tuple is used as a function closure. The modern way of
 
381
                  calling higher-order code in Erlang is by using proper funs.
 
382
                  The code should be rewritten using a proper 'fun' rather than
 
383
                  a 2-tuple since among other things makes the code cleaner and
 
384
                  is safer for execution in native code.</P>
 
385
              </ITEM>
 
386
            </LIST>
 
387
          </ITEM>
 
388
        </LIST>
 
389
      </ITEM>
 
390
      <ITEM>
 
391
        <P>Unsafe BEAM code</P>
 
392
        <LIST>
 
393
          <ITEM>
 
394
            <P>Warning:</P>
 
395
            <LIST>
 
396
              <ITEM>
 
397
                <P>"Unsafe BEAM code! Please recompile with a newer BEAM compiler."</P>
 
398
              </ITEM>
 
399
            </LIST>
 
400
          </ITEM>
 
401
          <ITEM>
 
402
            <P>Description:</P>
 
403
            <LIST>
 
404
              <ITEM>
 
405
                <P>The analysis has encountered BEAM bytecode which will fail in a
 
406
                  really bad way (even with a seg-fault) if used in an impoper way.
 
407
                  Such code was produced by the BEAM compiler of R9C-0 (and prior)
 
408
                  for some record expressions. The recommended action is to
 
409
                  generate a new .beam file using a newer version of the BEAM
 
410
                  compiler.</P>
 
411
              </ITEM>
 
412
            </LIST>
 
413
          </ITEM>
 
414
        </LIST>
 
415
      </ITEM>
 
416
    </LIST>
 
417
</SECTION>
 
418
 
 
419
 
 
420
<SECTION>
 
421
    <TITLE>Feedback & bug reports</TITLE>
 
422
 
 
423
<P>At this point, we very much welcome user feedback (even wish-lists!).
 
424
If you notice something weird, especially if the Dialyzer reports any
 
425
discrepancy that is a false positive, please send an error report
 
426
describing the symptoms and how to reproduce them</P>
 
427
</SECTION>
 
428
 
 
429
 
 
430
  <AUTHORS>
 
431
    <ANAME> Tobias Lindahl</ANAME>
 
432
    <EMAIL> tobias.lindahl@it.uu.se</EMAIL>
 
433
    <ANAME> Kostis Sagonas</ANAME>
 
434
    <EMAIL> kostis@it.uu.se</EMAIL>
 
435
  </AUTHORS>
 
436
</COMREF>
 
437
 
 
438
 
 
439
 
 
440
 
 
441
 
 
442
 
 
443