From e1f67dda7a9c2736f7b8d5d30fe84f2a2f39a8c1 Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Mon, 15 Nov 2010 15:44:54 +0200 Subject: Fix various dialyzer warnings Add appropriate specs to shut off dialyzer's no_return warnings and also fix an erroneous use of lists:concat/1 instead of lists:append/1. --- lib/edoc/src/edoc_layout.erl | 2 +- lib/edoc/src/edoc_lib.erl | 18 ++++++++++++++---- lib/edoc/src/edoc_macros.erl | 10 ++++++++-- lib/edoc/src/edoc_parser.yrl | 2 ++ lib/edoc/src/edoc_refs.erl | 2 -- lib/edoc/src/edoc_tags.erl | 13 +++++++++++++ lib/edoc/src/edoc_types.erl | 2 -- 7 files changed, 38 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/edoc/src/edoc_layout.erl b/lib/edoc/src/edoc_layout.erl index 900f0b3040..6cc2f5cd9b 100644 --- a/lib/edoc/src/edoc_layout.erl +++ b/lib/edoc/src/edoc_layout.erl @@ -482,7 +482,7 @@ local_defs([]) -> []; local_defs(Es) -> [?NL, {ul, [{class, "definitions"}], - lists:concat([[{li, [{tt, localdef(E)}]}, ?NL] || E <- Es])}]. + lists:append([[{li, [{tt, localdef(E)}]}, ?NL] || E <- Es])}]. localdef(E = #xmlElement{content = Es}) -> (case get_elem(typevar, Es) of diff --git a/lib/edoc/src/edoc_lib.erl b/lib/edoc/src/edoc_lib.erl index 5b7fb1e0d2..c1f95a7a67 100644 --- a/lib/edoc/src/edoc_lib.erl +++ b/lib/edoc/src/edoc_lib.erl @@ -288,11 +288,13 @@ parse_expr(S, L) -> %% content in e.g. %% `@author' tags. -%% @type info() = #info{name = string(), -%% mail = string(), -%% uri = string()} +%% @type info() = #info{name = string(), +%% email = string(), +%% uri = string()} --record(info, {name = "", email = "", uri = ""}). +-record(info, {name = "" :: string(), + email = "" :: string(), + uri = "" :: string()}). parse_contact(S, L) -> I = scan_name(S, L, #info{}, []), @@ -988,6 +990,14 @@ get_plugin(Key, Default, Opts) -> %% --------------------------------------------------------------------- %% Error handling +-type line() :: erl_scan:line(). +-type err() :: 'eof' + | {'missing', char()} + | {line(), atom(), string()} + | string(). + +-spec throw_error(err(), line()) -> no_return(). + throw_error({missing, C}, L) -> throw_error({"missing '~c'.", [C]}, L); throw_error(eof, L) -> diff --git a/lib/edoc/src/edoc_macros.erl b/lib/edoc/src/edoc_macros.erl index 2874e2940c..5b512cb53a 100644 --- a/lib/edoc/src/edoc_macros.erl +++ b/lib/edoc/src/edoc_macros.erl @@ -14,8 +14,6 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id$ -%% %% @private %% @copyright 2001-2005 Richard Carlsson %% @author Richard Carlsson @@ -317,6 +315,14 @@ macro_content([C | Cs], As, L, N) -> macro_content([], _As, _L, _N) -> throw('end'). +-type line() :: erl_scan:line(). +-type err() :: 'unterminated_macro' + | 'macro_name' + | {'macro_name', string()} + | {string(), [string()]}. + +-spec throw_error(line(), err()) -> no_return(). + throw_error(L, unterminated_macro) -> throw_error(L, {"unexpected end of macro.", []}); throw_error(L, macro_name) -> diff --git a/lib/edoc/src/edoc_parser.yrl b/lib/edoc/src/edoc_parser.yrl index 0eea8ae66f..91ee5a1b2b 100644 --- a/lib/edoc/src/edoc_parser.yrl +++ b/lib/edoc/src/edoc_parser.yrl @@ -404,6 +404,8 @@ parse_throws(S, L) -> %% --------------------------------------------------------------------- +-spec throw_error(term(), erl_scan:line()) -> no_return(). + throw_error({L, M, D}, _L0) -> throw({error,L,{format_error,M,D}}); throw_error({parse_spec, E}, L) -> diff --git a/lib/edoc/src/edoc_refs.erl b/lib/edoc/src/edoc_refs.erl index c2146bbe02..edc30674c0 100644 --- a/lib/edoc/src/edoc_refs.erl +++ b/lib/edoc/src/edoc_refs.erl @@ -14,8 +14,6 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id$ -%% %% @private %% @copyright 2003 Richard Carlsson %% @author Richard Carlsson diff --git a/lib/edoc/src/edoc_tags.erl b/lib/edoc/src/edoc_tags.erl index 1f2cb99c75..c0b861e08a 100644 --- a/lib/edoc/src/edoc_tags.erl +++ b/lib/edoc/src/edoc_tags.erl @@ -330,6 +330,10 @@ parse_typedef(Data, Line, _Env, _Where) -> Def end. +-type line() :: erl_scan:line(). + +-spec parse_file(_, line(), _, _) -> no_return(). + parse_file(Data, Line, Env, _Where) -> case edoc_lib:parse_expr(Data, Line) of {string, _, File0} -> @@ -344,6 +348,8 @@ parse_file(Data, Line, Env, _Where) -> throw_error(Line, file_not_string) end. +-spec parse_header(_, line(), _, _) -> no_return(). + parse_header(Data, Line, Env, {Where, _}) -> parse_header(Data, Line, Env, Where); parse_header(Data, Line, Env, Where) when is_list(Where) -> @@ -362,6 +368,13 @@ parse_header(Data, Line, Env, Where) when is_list(Where) -> throw_error(Line, file_not_string) end. +-type err() :: 'file_not_string' + | {'file_not_found', file:filename()} + | {'read_file', file:filename(), term()} + | string(). + +-spec throw_error(line(), err()) -> no_return(). + throw_error(L, {read_file, File, R}) -> throw_error(L, {"error reading file '~s': ~w", [edoc_lib:filename(File), R]}); diff --git a/lib/edoc/src/edoc_types.erl b/lib/edoc/src/edoc_types.erl index 85c9ee6f2a..b0255f793d 100644 --- a/lib/edoc/src/edoc_types.erl +++ b/lib/edoc/src/edoc_types.erl @@ -14,8 +14,6 @@ %% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 %% USA %% -%% $Id$ -%% %% @private %% @copyright 2001-2003 Richard Carlsson %% @author Richard Carlsson -- cgit v1.2.3