[erlang-patches] dialyzer: Report specs defining 'incorrect' lists as return types

Stavros Aronis <>
Fri Dec 14 10:11:25 CET 2012


This patch enables Dialyzer to detect cases where a function has a
specification for a return type containing some list with elements
different than those Dialyzer's own algorithm can infer e.g. a function
specified to return [atom()] when actually [[atom()]] is returned.

Previously Dialyzer remained silent under normal operation, seeing that
these two types have the empty list as a common element, so the spec was
not 'completely irrelevant'.

Using this patch one can find discrepancies in the specs of
stdlib's sys.erl and erl_scan.erl. Kostis and I are in contact with the OTP
team for the best way fix those as well.

  git fetch git://github.com/aronisstav/otp.git dialyzer-list-spec

Regards,

Stavros

---

The new warnings are:

sys.erl:303: Invalid type specification for function sys:handle_debug/4.
The success typing is ([{_,_}],_,_,_) -> [{_,_}]
 erl_scan.erl:204: Invalid type specification for function
erl_scan:token_info/2. The success typing is (_,'category' | 'column' |
'length' | 'line' | 'location' | 'symbol' | 'text' |
maybe_improper_list('category' | 'column' | 'length' | 'line' | 'location'
| 'symbol' | 'text','category' | 'column' | 'length' | 'line' | 'location'
| 'symbol' | 'text' | [])) -> 'undefined' |
maybe_improper_list({_,_},'undefined' | [] | {_,_}) | {_,_}
erl_scan.erl:242: Invalid type specification for function
erl_scan:attributes_info/2. The success typing is (_,'column' | 'length' |
'line' | 'location' | 'text' | maybe_improper_list('column' | 'length' |
'line' | 'location' | 'text','column' | 'length' | 'line' | 'location' |
'text' | [])) -> 'undefined' | maybe_improper_list({_,_},'undefined' | [] |
{_,_}) | {_,_}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20121214/c207a987/attachment.html>


More information about the erlang-patches mailing list