diff options
author | Hans Bolinder <hasse@erlang.org> | 2021-06-10 10:10:03 +0200 |
---|---|---|
committer | Hans Bolinder <hasse@erlang.org> | 2021-06-10 10:10:03 +0200 |
commit | 93709c1cc60b76afddedf69abe32e5203ca39be5 (patch) | |
tree | b8b98ae859b37ce7d3d44c9c46fa1fc0409c93a1 /lib/stdlib/test/erl_lint_SUITE.erl | |
parent | ca4a869538ef4792115c1ed7f027e4bd3525fa2b (diff) | |
parent | 59cc16df4cb0b171e09e38e7924b7d719af1f834 (diff) | |
download | erlang-93709c1cc60b76afddedf69abe32e5203ca39be5.tar.gz |
Merge branch 'hasse/stdlib/linter_unused_types/OTP-17370/GH-4784'
* hasse/stdlib/linter_unused_types/OTP-17370/GH-4784:
stdlib: Let the linter check unused types properly
stdlib: Let the linter report all locations for undef types
Diffstat (limited to 'lib/stdlib/test/erl_lint_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/erl_lint_SUITE.erl | 67 |
1 files changed, 64 insertions, 3 deletions
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index 306b06ce5b..7349b7a2e2 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -74,7 +74,8 @@ warn_missing_spec/1, otp_16824/1, underscore_match/1, - unused_record/1]). + unused_record/1, + unused_type2/1]). suite() -> [{ct_hooks,[ts_install_cth]}, @@ -98,7 +99,7 @@ all() -> stacktrace_syntax, otp_14285, otp_14378, external_funs, otp_15456, otp_15563, unused_type, binary_types, removed, otp_16516, inline_nifs, warn_missing_spec, otp_16824, - underscore_match, unused_record]. + underscore_match, unused_record, unused_type2]. groups() -> [{unused_vars_warn, [], @@ -3724,7 +3725,10 @@ predef(Config) when is_list(Config) -> %% dict(), digraph() and so on were removed in Erlang/OTP 18.0. E2 = get_compilation_result(Config, "predef2", []), Tag = undefined_type, - {[{{7,13},erl_lint,{Tag,{array,0}}}, + {[{{5,2},erl_lint,{Tag,{array,0}}}, + {{5,2},erl_lint,{Tag,{digraph,0}}}, + {{5,2},erl_lint,{Tag,{gb_set,0}}}, + {{7,13},erl_lint,{Tag,{array,0}}}, {{12,12},erl_lint,{Tag,{dict,0}}}, {{17,15},erl_lint,{Tag,{digraph,0}}}, {{27,14},erl_lint,{Tag,{gb_set,0}}}, @@ -4630,6 +4634,63 @@ unused_record(Config) when is_list(Config) -> ok. +unused_type2(Config) when is_list(Config) -> + Ts = [{unused_type2_1, + <<"-type t() :: [t()]. + t() -> + a. + ">>, + {[]}, + {warnings,[{{1,22},erl_lint,{unused_type,{t,0}}}, + {{2,15},erl_lint,{unused_function,{t,0}}}]}}, + {unused_type2_2, + <<"-type t1() :: t2(). + -type t2() :: t1(). + t() -> + a. + ">>, + {[]}, + {warnings,[{{1,22},erl_lint,{unused_type,{t1,0}}}, + {{2,16},erl_lint,{unused_type,{t2,0}}}, + {{3,16},erl_lint,{unused_function,{t,0}}}]}}, + {unused_type2_3, + <<"-callback cb() -> t(). + -type t() :: atom(). + t() -> + a. + ">>, + {[]}, + {warnings,[{{3,16},erl_lint,{unused_function,{t,0}}}]}}, + {unused_type2_4, + <<"-spec t() -> t(). + -type t() :: atom(). + t() -> + a. + ">>, + {[]}, + {warnings,[{{3,16},erl_lint,{unused_function,{t,0}}}]}}, + {unused_type2_5, + <<"-export_type([t/0]). + -type t() :: atom(). + t() -> + a. + ">>, + {[]}, + {warnings,[{{3,16},erl_lint,{unused_function,{t,0}}}]}}, + {unused_type2_6, + <<"-record(r, {f :: t()}). + -type t() :: atom(). + t() -> + a. + ">>, + {[]}, + {warnings,[{{1,22},erl_lint,{unused_record,r}}, + {{3,16},erl_lint,{unused_function,{t,0}}}]}} + ], + [] = run(Config, Ts), + + ok. + format_error(E) -> lists:flatten(erl_lint:format_error(E)). |