Dialyzer: Cons will produce an improper list since its 2nd argument is none()

Dmitry Belyaev be.dmitry@REDACTED
Fri Feb 14 14:56:46 CET 2020


When a tool does something incorrect, and I think everybody agree that first and second warnings are incorrect, those are called bugs, not features.

And when something incorrect is purposefully sneaked in, then one may ask a question what else undesirable may be purposefully added. It could be a routine sending private code to professional human code review to ensure the high quality and absence of bugs.

On 14 February 2020 11:53:23 pm AEDT, Kostis Sagonas <kostis@REDACTED> wrote:
>On 2/14/20 1:44 PM, Jesper Eskilson wrote:
>> Hi,
>> 
>> When dialyzer analyzes this program:
>> 
>> 
>>     -module(foo).
>>     -export([main/0]).
>>     -record(foo, {x :: integer()}).
>>     main() ->
>>        [ #foo{x = 0},
>>          #foo{x = false} ].
>> 
>> 
>> it says:
>> 
>>     foo.erl:7: Function main/0 has no local return
>>     foo.erl:8: Cons will produce an improper list since its 2nd
>argument is
>>                none()
>>     foo.erl:9: Record construction
>>                #foo{x :: false} violates the declared type of field x
>::
>>                integer()
>> 
>> 
>> It seems like dialyzer assumes that any cons with second argument not
>
>> being a list will produce an improper list, but shouldn't it treat 
>> "none()" differently?
>> 
>> Is this a bug in dialyzer, or a feature whose usefulness I am unable
>to 
>> grasp?
>
>It's a dialyzer feature, which we have purposedly sneaked into the tool
>
>to discover all users who choose to stop reading all warnings that the 
>tool spits out and are not experienced enough to realize that once they
>
>fix the real culprit, which may not be the first warning that that the 
>tool produces, the other warnings will also disappear.
>
>Cheers,
>Kostis

-- 
Kind regards,
Dmitry Belyaev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200215/0166c8f1/attachment.htm>


More information about the erlang-questions mailing list