Quantcast

dialyzer: false function has no local return warning in R14B?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

dialyzer: false function has no local return warning in R14B?

Klas Johansson
Hi,

I get a warning from dialyzer when using ets:select (test case
attached), but it seems like a false warning.  The fact that the key
(#r.k) is a tuple rather than an atom seems important - there's no
warning if it's an atom.

This is on R14B (as well as earlier versions).

Any ideas?

Thanks,
Klas


________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

x.erl (452 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dialyzer: false function has no local return warning in R14B?

Kostis Sagonas-2
Klas Johansson wrote:

> Hi,
>
> I get a warning from dialyzer when using ets:select (test case
> attached), but it seems like a false warning.  The fact that the key
> (#r.k) is a tuple rather than an atom seems important - there's no
> warning if it's an atom.
>
> This is on R14B (as well as earlier versions).
>
> Any ideas?

You are sort of right that this is related to the declaration of #r{}
and its fields. But this is not a dialyzer bug!

Instead, it's a bug in the ms_transform parse transformation which is
not aware of type declarations in records and messes up things.

To verify that this is the case either comment out the line:

-include_lib("stdlib/include/ms_transform.hrl").

which enables the parse transform, or simply take out the type
declaration from the record.  Dialyzer will then like your module :-)

I am leaving this to the person responsible for the ms parse transform
to fix.

Kostis

________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dialyzer: false function has no local return warning in R14B?

Klas Johansson
On Thu, Nov 4, 2010 at 11:22 PM, Kostis Sagonas <[hidden email]> wrote:

> Klas Johansson wrote:
>>
>> Hi,
>>
>> I get a warning from dialyzer when using ets:select (test case
>> attached), but it seems like a false warning.  The fact that the key
>> (#r.k) is a tuple rather than an atom seems important - there's no
>> warning if it's an atom.
>>
>> This is on R14B (as well as earlier versions).
>>
>> Any ideas?
>
> You are sort of right that this is related to the declaration of #r{} and
> its fields. But this is not a dialyzer bug!
>
> Instead, it's a bug in the ms_transform parse transformation which is not
> aware of type declarations in records and messes up things.
>
> To verify that this is the case either comment out the line:
>
> -include_lib("stdlib/include/ms_transform.hrl").
>
> which enables the parse transform, or simply take out the type declaration
> from the record.  Dialyzer will then like your module :-)
>
> I am leaving this to the person responsible for the ms parse transform to
> fix.

Ah, I see what's happening here.  The parse transform generates this
match specification for me:

    [{{r,'_'},[],['$_']}]    which is the same as    [{#r{_='_'},[],['$_']}]

... but this doesn't match the type specs ('_' is an atom, not a tuple):

    -type k() :: {term(), term()}.
    -record(r, {k :: k()}).

Tricky.  Thanks for your help.


BR,
Klas

________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Loading...