aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2016-10-20 14:19:18 +0200
committerHans Bolinder <[email protected]>2016-10-21 09:08:41 +0200
commit56b3298377c7422345076f342c0d99901aee34fc (patch)
tree59a350ed57e90914ae88c14fe85f80475bac8403 /lib/dialyzer/test
parent9a7f521f9d6eba398af2e703863f9975911085a4 (diff)
downloadotp-56b3298377c7422345076f342c0d99901aee34fc.tar.gz
otp-56b3298377c7422345076f342c0d99901aee34fc.tar.bz2
otp-56b3298377c7422345076f342c0d99901aee34fc.zip
dialyzer: Fix error handling of bad -dialyzer() attributes
If a dialyzer module attribute references an undefined (local) function an error tuple is thrown but no caught. This leads to a 'nocatch' error and not the intended "clean" error.
Diffstat (limited to 'lib/dialyzer/test')
-rw-r--r--lib/dialyzer/test/plt_SUITE.erl30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/dialyzer/test/plt_SUITE.erl b/lib/dialyzer/test/plt_SUITE.erl
index 6ebe23b54b..460d4e2240 100644
--- a/lib/dialyzer/test/plt_SUITE.erl
+++ b/lib/dialyzer/test/plt_SUITE.erl
@@ -8,13 +8,15 @@
-export([suite/0, all/0, build_plt/1, beam_tests/1, update_plt/1,
local_fun_same_as_callback/1,
- remove_plt/1, run_plt_check/1, run_succ_typings/1]).
+ remove_plt/1, run_plt_check/1, run_succ_typings/1,
+ bad_dialyzer_attr/1]).
suite() ->
[{timetrap, ?plt_timeout}].
all() -> [build_plt, beam_tests, update_plt, run_plt_check,
- remove_plt, run_succ_typings, local_fun_same_as_callback].
+ remove_plt, run_succ_typings, local_fun_same_as_callback,
+ bad_dialyzer_attr].
build_plt(Config) ->
OutDir = ?config(priv_dir, Config),
@@ -249,6 +251,30 @@ remove_plt(Config) ->
{init_plt, Plt}] ++ Opts),
ok.
+bad_dialyzer_attr(Config) ->
+ PrivDir = ?config(priv_dir, Config),
+
+ Prog1 = <<"-module(dial).
+ -dialyzer({no_return, [undef/0]}).">>,
+ {ok, Beam1} = compile(Config, Prog1, dial, []),
+ Plt = filename:join(PrivDir, "bad_attr.plt"),
+ {dialyzer_error,
+ "Analysis failed with error:\n"
+ "Could not scan the following file(s):\n"
+ " Unknown function undef/0 in line " ++ _} =
+ (catch run_dialyzer(plt_build, [Beam1], [])),
+
+ Prog2 = <<"-module(dial).
+ -dialyzer({no_return, [{undef,1,2}]}).">>,
+ {ok, Beam2} = compile(Config, Prog2, dial, []),
+ {dialyzer_error,
+ "Analysis failed with error:\n"
+ "Could not scan the following file(s):\n"
+ " Bad function {undef,1,2} in line " ++ _} =
+ (catch run_dialyzer(plt_build, [Beam2], [])),
+
+ ok.
+
compile(Config, Prog, Module, CompileOpts) ->
Source = lists:concat([Module, ".erl"]),
PrivDir = ?config(priv_dir,Config),