[erlang-questions] Why does Dialyzer crash on this map?

Björn-Egil Dahlberg wallentin.dahlberg@REDACTED
Thu Nov 27 21:52:36 CET 2014


Looks like the regression was introduced in
'hb/dialyzer/fix_recognition_of_records/OTP-11935'
(805f9c89fc01220bc1bb0f27e1b68fd4eca688ba) included from OTP 17.1

This becomes a none-issue in the master branch (for 18) since variables are
allowed as keys there but it needs to be solved for the 17 track.


2014-11-27 21:13 GMT+01:00 Björn-Egil Dahlberg <wallentin.dahlberg@REDACTED
>:

> I managed to reproduce your errors on dt.erl and dt2.erl using OTP-17.3.3
> tag.
>
> Seems like I've missed something in dataflow .. looks like a clause
> missing for the map type.
> I'm not well versed in dialyzer. Hopefully I can do a fix for it for 17.4.
>
> There are a bit more stuff going on here too. When dialyzer uses the
> erlang compiler to compile to core
> it does not coalesce things to literals but keeps them abstract instead ..
> Compound keys such as [1,2,3] and {4,5,6} will thus become non-literals
> (variables) and such keys are not allowed in maps.
>
> I need to ponder that a bit before I try to solve it.
>
> // Björn-Egil
>
> 2014-11-27 13:20 GMT+01:00 Ivan Uemlianin <ivan@REDACTED>:
>
>> Dear Dave
>>
>> Thanks for your help.  Here are some more details:
>>
>>
>> *** OS: FreeBSD 10.0-RELEASE
>>
>> $ uname -a
>> FreeBSD simba 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16
>> 22:34:59 UTC 2014 root@REDACTED:/usr/obj/usr/src/sys/GENERIC
>> amd64
>>
>> Upgrading to 10.1 is on my todo list.
>>
>>
>> *** Erlang version now 17.3_3,3
>>
>> $ pkg info erlang
>> erlang-17.3_1,3
>> ...
>> $ sudo pkg upgrade
>> ...
>>
>> $ pkg info erlang
>> erlang-17.3_3,3
>> ...
>>
>>
>> *** Errors persist
>>
>> Upgrading erlang has not changed behaviour.
>>
>> A couple more observations:
>>
>> 1. Running dialyzer on the module dt below gets the error as noted
>> previously.  However, if I uncomment the '%% ok' line, dialyzer will
>> process the module with no problems.
>>
>>     -module(dt).
>>     -export([get_map/0]).
>>
>>     -spec get_map() -> map().
>>     get_map() ->
>>         #{labels => [one, two],
>>           number => 27,
>> %%          [1,2,3] => wer,        %% ok
>>           kvok => #{
>>                 a => qwe,
>>                 2 => asd,
>>                 [1,2,3] => wer,  %% bad
>>                 {4,5,6} => sdf,  %% bad
>>                 "abc" => zxc
>>            }
>>          }.
>>
>>     $ dialyzer dt.erl
>>       Checking whether the PLT /home/ivan/.dialyzer_plt is up-to-date...
>> yes
>>       Proceeding with analysis...
>>     =ERROR REPORT==== 27-Nov-2014::12:17:02 ===
>>     Error in process <0.45.0> with exit value:
>> {{case_clause,map},[{dialyzer_dataflow,find_terminals,1,[{
>> file,"dialyzer_dataflow.erl"},{line,3451}]},{dialyzer_
>> dataflow,find_terminals_list,3,[{file,"dialyzer_dataflow.
>> erl"},{line,3504}]},{dialyzer_dataflow,classify_returns...
>>
>>
>>     dialyzer: Analysis failed with error:
>>     {{case_clause,map},
>>      [{dialyzer_dataflow,find_terminals,1,
>> [{file,"dialyzer_dataflow.erl"},{line,3451}]},
>>       {dialyzer_dataflow,find_terminals_list,3,
>> [{file,"dialyzer_dataflow.erl"},{line,3504}]},
>>       {dialyzer_dataflow,classify_returns,1,
>> [{file,"dialyzer_dataflow.erl"},{line,3443}]},
>>       {dialyzer_dataflow,'-state__get_warnings/2-fun-0-',7,
>> [{file,"dialyzer_dataflow.erl"},{line,2908}]},
>>       {lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
>>       {dialyzer_dataflow,state__get_warnings,2,
>> [{file,"dialyzer_dataflow.erl"},{line,2934}]},
>>       {dialyzer_dataflow,get_warnings,5,
>> [{file,"dialyzer_dataflow.erl"},{line,142}]},
>>       {dialyzer_succ_typings,collect_warnings,2,
>> [{file,"dialyzer_succ_typings.erl"},{line,182}]}]}
>>     Last messages in the log cache:
>>       Reading files and computing callgraph... done in 0.07 secs
>>       Removing edges... done in 0.00 secs
>>
>>
>> 2. Running dialyzer on the module dt2 below raises the warning
>> following.  Uncommenting the '%% ok' line has no effect.
>>
>>     -module(dt2).
>>     -export([get_map/0]).
>>
>>     -spec get_map() -> map().
>>     get_map() ->
>>         X = #{labels => [one, two],
>>           number => 27,
>> %%          [1,2,3] => wer,        %% ok
>>           kvok => #{
>>                 a => qwe,
>>                 2 => asd,
>>                 [1,2,3] => wer,  %% bad
>>                 {4,5,6} => sdf,  %% bad
>>                 "abc" => zxc
>>            }
>>          },
>>         X.
>>
>>     $ dialyzer dt2.erl
>>       Checking whether the PLT /home/ivan/.dialyzer_plt is up-to-date...
>> yes
>>       Proceeding with analysis...
>>     dt2.erl:5: Function get_map/0 has no local return
>>      done in 0m0.41s
>>     done (warnings were emitted)
>>
>> Best wishes
>>
>> Ivan
>>
>>
>>
>>
>> On 11/25/14 20:37, Dave Cottlehuber wrote:
>>
>>> Sorry about that last email …
>>>
>>> EWORKSFORME.
>>>
>>> FreeBSD 10.1 amd64, erlang-17.3_2,3 from pkg.
>>>
>>> What FreeBSD & erlang are you using?
>>>
>>> dch   /tmp ❯❯❯   dialyzer --build_plt --apps erts kernel stdlib
>>>    Creating PLT /home/dch/.dialyzer_plt ...
>>> Unknown functions:
>>>    compile:file/2
>>>    compile:forms/2
>>>    compile:noenv_forms/2
>>>    compile:output_generated/1
>>>    crypto:block_decrypt/4
>>>    crypto:start/0
>>> Unknown types:
>>>    compile:option/0
>>>   done in 1m8.53s
>>> done (passed successfully)
>>>
>>> dch   /tmp ❯❯❯dialyzer ltu.erl
>>>    Checking whether the PLT /home/dch/.dialyzer_plt is up-to-date... yes
>>>    Proceeding with analysis... done in 0m0.41s
>>> done (passed successfully)
>>>
>>> dch   /tmp ❯❯❯erl
>>> Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:8:8] [async-threads:64]
>>> [kernel-poll:true]
>>>
>>> Eshell V6.2  (abort with ^G)
>>> 1>
>>>
>>> A+, Dave
>>> — sent from my Couch
>>>
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>
>> --
>> ============================================================
>> Ivan A. Uemlianin PhD
>> Llaisdy
>> Speech Technology Research and Development
>>
>>                     ivan@REDACTED
>>                         @llaisdy
>>                          llaisdy.wordpress.com
>>               github.com/llaisdy
>>                      www.linkedin.com/in/ivanuemlianin
>>
>>                         festina lente
>> ============================================================
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141127/7024c33c/attachment.htm>


More information about the erlang-questions mailing list