61
61
try check_gui_options(Opts)
62
62
catch throw:{dialyzer_error, Msg} -> cl_error(Msg)
64
case cl_check_init(Opts) of
65
{error, _} = Error -> gui_halt(Error, Opts);
66
{ok, ?RET_NOTHING_SUSPICIOUS} ->
64
case Opts#options.check_plt of
66
case cl_check_init(Opts#options{get_warnings=false}) of
67
{error, _} = Error -> cl_halt(Error, Opts);
68
{ok, _} -> gui_halt(internal_gui(Opts), Opts)
67
71
gui_halt(internal_gui(Opts), Opts)
70
case cl_check_init(Opts) of
71
{error, _} = Error -> cl_halt(Error, Opts);
72
{ok, ?RET_NOTHING_SUSPICIOUS} ->
74
case Opts#options.check_plt of
76
case cl_check_init(Opts#options{get_warnings=false}) of
77
{error, _} = Error -> cl_halt(Error, Opts);
78
{ok, _} -> cl_halt(cl(Opts), Opts)
73
81
cl_halt(cl(Opts), Opts)
105
113
Msg = io_lib:format("Could not read the plt file ~p\n", [Plt]),
106
114
throw({dialyzer_error, Msg});
107
115
{error, no_such_file} ->
108
Msg = io_lib:format("The plt file ~p does not exist.\n", [Plt]),
116
Msg = io_lib:format("The plt file ~p does not exist\n", [Plt]),
109
117
throw({dialyzer_error, Msg})
111
119
case Opts#options.output_file of
198
206
Msg = io_lib:format("Analysis mode ~w is illegal in gui mode", [Mode]),
199
207
throw({dialyzer_error, Msg}).
201
-spec(plt_info/1 :: (string()) -> {ok, [{'files', [string()]}]}
209
-spec plt_info(string()) -> {ok, [{'files', [string()]}]} | {error, atom()}.
205
212
case dialyzer_plt:included_files(Plt) of
226
233
gui_halt(R, Opts) ->
227
234
cl_halt(R, Opts#options{report_mode=quiet}).
230
({'ok',atom()} | {'error',string()}, #options{}) -> no_return()).
236
-spec cl_halt({'ok',dial_ret()} | {'error',string()}, #options{}) -> no_return().
232
238
cl_halt({ok, R = ?RET_NOTHING_SUSPICIOUS}, #options{report_mode=quiet}) ->
246
252
cl_check_log(Output),
247
253
halt(?RET_INTERNAL_ERROR).
249
-spec(cl_check_log/1 :: (string()) -> 'ok').
255
-spec cl_check_log(string()) -> 'ok'.
251
257
cl_check_log(none) ->
253
259
cl_check_log(Output) ->
254
260
io:format(" Check output file `~s' for details\n", [Output]).
256
-spec(format_warning/1 :: (dial_warning()) -> string()).
262
-spec format_warning(dial_warning()) -> string().
258
264
format_warning({_Tag, {File, Line}, Msg}) when is_list(File),
259
265
is_integer(Line) ->
285
291
message_to_string({improper_list_constr, [TlType]}) ->
286
292
io_lib:format("Cons will produce an improper list since its "
287
293
"2nd argument is ~s\n", [TlType]);
294
message_to_string({record_matching, [String, Name]}) ->
295
io_lib:format("The ~s violates the "
296
"declared type for #~w{}\n", [String, Name]);
288
297
message_to_string({record_constr, [Types, Name]}) ->
289
298
io_lib:format("Record construction ~s violates the "
290
299
"declared type for #~w{}\n", [Types, Name]);
301
310
message_to_string({guard_fail, []}) ->
302
311
"Clause guard cannot succeed.\n";
303
312
message_to_string({guard_fail, [Arg1, Infix, Arg2]}) ->
304
io_lib:format("Guard test ~s ~s ~s can never succeed.\n",
313
io_lib:format("Guard test ~s ~s ~s can never succeed\n",
305
314
[Arg1, Infix, Arg2]);
306
315
message_to_string({guard_fail, [Guard, Args]}) ->
307
316
io_lib:format("Guard test ~w~s can never succeed\n", [Guard, Args]);
326
335
message_to_string({spec_missing_fun, [M, F, A]}) ->
327
336
io_lib:format("Contract for function that does not exist: ~w:~w/~w\n",
329
338
message_to_string({invalid_contract, [M, F, A, Sig]}) ->
330
339
io_lib:format("Invalid type specification for function ~w:~w/~w. "
331
340
"The success typing is ~s\n",
333
342
message_to_string({overlapping_contract, []}) ->
334
343
"Overloaded contract has overlapping domains;"
335
" such contracts are currently unsupported and are simply ignored \n";
344
" such contracts are currently unsupported and are simply ignored\n";
336
345
message_to_string({contract_subtype, [M, F, A, Contract, Sig]}) ->
337
346
io_lib:format("Type specification ~w:~w/~w :: ~s "
338
347
"is a subtype of the success typing: ~s\n",
339
348
[M, F, A, Contract, Sig]);
340
349
message_to_string({contract_supertype, [M, F, A, Contract, Sig]}) ->
341
350
io_lib:format("Type specification ~w:~w/~w :: ~s "
342
"is a supertype of the success typing: ~s\n",
351
"is a supertype of the success typing: ~s\n",
343
352
[M, F, A, Contract, Sig]);
344
353
message_to_string({contract_diff, [M, F, A, Contract, Sig]}) ->
345
354
io_lib:format("Type specification ~w:~w/~w :: ~s "
346
"is not equal to the success typing: ~s\n",
355
"is not equal to the success typing: ~s\n",
347
356
[M, F, A, Contract, Sig]);
348
357
message_to_string({call_to_missing, [M, F, A]}) ->
349
358
io_lib:format("Call to missing or unexported function ~w:~w/~w\n", [M, F, A]);
367
376
case ArgNs =:= [] of
369
%% We do not know which arguments that caused the failure.
370
io_lib:format("will fail since the success typing arguments"
378
%% We do not know which arguments caused the failure.
379
io_lib:format("will never return since the success typing arguments"
371
380
" are ~s\n", [SigArgs]);
373
io_lib:format("will fail since it differs in argument"
382
io_lib:format("will never return since it differs in argument"
374
383
" ~s from the success typing arguments: ~s\n",
375
384
[PositionString, SigArgs])
378
387
case (ArgNs =:= []) orelse IsOverloaded of
380
%% We do not know which arguments that caused the failure.
389
%% We do not know which arguments caused the failure.
381
390
io_lib:format("breaks the contract ~s\n", [Contract]);
383
392
io_lib:format("breaks the contract ~s in argument ~s\n",
384
393
[Contract, PositionString])
387
io_lib:format("will fail since the success typing is ~s -> ~s and "
388
"the contract is ~s\n", [SigArgs, SigRet, Contract])
396
io_lib:format("will never return since the success typing is ~s -> ~s"
397
" and the contract is ~s\n", [SigArgs, SigRet, Contract])