diff options
author | Björn Gustavsson <[email protected]> | 2010-10-29 14:44:35 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-10-29 14:44:35 +0200 |
commit | 76378bb4a1a89d08b41d6f3df0edc6c26160bef7 (patch) | |
tree | a2a7536973fe1b23c129bd5c24a47334da2311cb /lib | |
parent | c14970e178a7cef8dcb214653f9fc9b6c741ce10 (diff) | |
parent | e041319e4a4c451c5ec090d2ea64f545aeaadb78 (diff) | |
download | otp-76378bb4a1a89d08b41d6f3df0edc6c26160bef7.tar.gz otp-76378bb4a1a89d08b41d6f3df0edc6c26160bef7.tar.bz2 otp-76378bb4a1a89d08b41d6f3df0edc6c26160bef7.zip |
Merge branch 'ks/bad-export_type' into dev
* ks/bad-export_type:
Avoid errors for a badly formed export_type declarations
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/erl_lint.erl | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index 077621ac91..0c2d3db8ec 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -311,6 +311,8 @@ format_error({ill_defined_behaviour_callbacks,Behaviour}) -> %% --- types and specs --- format_error({singleton_typevar, Name}) -> io_lib:format("type variable ~w is only used once (is unbound)", [Name]); +format_error({bad_export_type, _ETs}) -> + io_lib:format("bad export_type declaration", []); format_error({duplicated_export_type, {T, A}}) -> io_lib:format("type ~w/~w already exported", [T, A]); format_error({undefined_type, {TypeName, Arity}}) -> @@ -1128,8 +1130,7 @@ export(Line, Es, #lint{exports = Es0, called = Called} = St0) -> export_type(Line, ETs, #lint{usage = Usage, exp_types = ETs0} = St0) -> UTs0 = Usage#usage.used_types, - {ETs1,UTs1,St1} = - foldl(fun (TA, {E,U,St2}) -> + try foldl(fun ({T,A}=TA, {E,U,St2}) when is_atom(T), is_integer(A) -> St = case gb_sets:is_element(TA, E) of true -> Warn = {duplicated_export_type,TA}, @@ -1139,8 +1140,13 @@ export_type(Line, ETs, #lint{usage = Usage, exp_types = ETs0} = St0) -> end, {gb_sets:add_element(TA, E), dict:store(TA, Line, U), St} end, - {ETs0,UTs0,St0}, ETs), - St1#lint{usage = Usage#usage{used_types = UTs1}, exp_types = ETs1}. + {ETs0,UTs0,St0}, ETs) of + {ETs1,UTs1,St1} -> + St1#lint{usage = Usage#usage{used_types = UTs1}, exp_types = ETs1} + catch + error:_ -> + add_error(Line, {bad_export_type, ETs}, St0) + end. -type import() :: {module(), [fa()]} | module(). -spec import(line(), import(), lint_state()) -> lint_state(). |