<div dir="ltr"><div style>Hello</div><div style><br></div><div style>At Montenegro Erlang Hackaton ( <a href="http://lanyrd.com/2013/herceg-novi-erlang-meetup/">http://lanyrd.com/2013/herceg-novi-erlang-meetup/</a> , there were only two people, unfortunately ) we found incorrect behaviour of Dialyzer.<br>

</div><div style><br></div><div style>Our project erroneous had a duplicated modules with the same name, but different content. When we check it with dialyzer it show me something like that:</div><div style><br></div><div style>

<div>Duplicate modules: [["/var/tmp/myproj/apps/myproj/ebin/psc_operate.beam",</div><div>                     "/var/tmp/myproj/deps/somedep/ebin/amp_common_utils.beam"]]</div><div><br></div><div style>

Obviously it is not the same modules. So I had to search this bug and find strange behaviour in dialyzer. Function lists:zip/2 called with two list, where first is reversed list of modules as atom, and second is list of filepaths for modules. And this list not always contains correspond elements. Module with name some_module1 can be has filename like abc_module55.beam. This is the cause of error.</div>

<div style><br></div><div style>This bug exists in R15B02 and R16.</div><div style><br></div><div style>I wrote such patch to fix bug, but I don't know whether this is solution or not, though it works fine.</div></div>

<div><br></div><div>--- /opt/r16a/lib/dialyzer-2.5.4/src/dialyzer_analysis_callgraph.erl    2013-01-31 12:55:53.210402846 +0700</div><div>+++ dialyzer_pa/dialyzer_analysis_callgraph.erl 2013-03-21 13:20:46.794991889 +0700</div>

<div>@@ -255,10 +255,18 @@</div><div>   CServer2 = dialyzer_codeserver:set_next_core_label(NextLabel, CServer),</div><div>   case Failed =:= [] of</div><div>     true -></div><div>-      NewFiles = lists:zip(lists:reverse(Modules), Files),</div>

<div>+      %% Modules and Files have not the same order, so it is meaningless to zip it</div><div>+      %% NewFiles = lists:zip(lists:reverse(Modules), Files),</div><div>+</div><div>       ModDict =</div><div>-        lists:foldl(fun({Mod, F}, Dict) -> dict:append(Mod, F, Dict) end,</div>

<div>-                    dict:new(), NewFiles),</div><div>+        lists:foldl(fun(F, Dict) -></div><div>+                        ModFile = lists:last(filename:split(F)),</div><div>+                        Mod = filename:basename(ModFile, ".beam"),</div>

<div>+                        dict:append(Mod, F, Dict) end,</div><div>+                    dict:new(), Files),</div><div>+      %% ModDict =</div><div>+      %%   lists:foldl(fun({Mod, F}, Dict) -> dict:append(Mod, F, Dict) end,</div>

<div>+      %%               dict:new(), NewFiles),</div><div>       check_for_duplicate_modules(ModDict);</div><div>     false -></div><div>       Msg = io_lib:format("Could not scan the following file(s): ~p",</div>

<div><br></div><div><br></div>-- <br>Max Treskin
</div>