<div dir="auto">Probably because proplists:proplist() is not in your PLT.</div><div dir="auto"><br></div><div dir="auto">Have you tried enabling the unknown warning for dialyzer?</div><div dir="auto"><br></div><div dir="auto">It will likely tell you that it doesn't know the proplists:proplist/0 type.</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 17 May 2021 at 22:25 Paulo Zulato <<a href="mailto:paulozulato@gmail.com">paulozulato@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr"><div>Hello,</div><div><br></div><div>I'm trying to figure out why dialyzer is complaining about a function when I don't explicitly declare its return as a proplist.<br></div><div>I have this small module which returns a proplist in the form <span style="font-family:monospace">{atom(), [atom()]}</span>:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><span style="font-family:monospace"><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,104,24)">-module</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">(</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">test</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">).
</span></span><br><span style="font-family:monospace">
</span><br><span style="font-family:monospace"><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,104,24)">-export</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">(</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">[</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">test</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,104,24)">/</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">0</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">]</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">).
</span></span><br><span style="font-family:monospace">
test() <span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,104,24)">-></span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)"> </span></span><br><span style="font-family:monospace"> <span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">[</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)"> </span></span><br><span style="font-family:monospace"> <span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">{</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">one_test</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">, </span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">[</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">a</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">,</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">b</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">,</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">c</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">]}</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">,
</span></span><br><span style="font-family:monospace"> <span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">{</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">another_test</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">, </span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">[</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">d</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">,</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">e</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">,</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,24)">f</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">]}</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">
</span></span><br><span style="font-family:monospace"> <span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(178,24,178)">]</span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">.</span></span><br><span style="font-family:monospace"></span></blockquote><br><div>For function above, I made the following spec, but dialyzer has complained (as stated below) when I enabled its underspecs warnings<span style="font-family:monospace"><span style="font-family:monospace;background-color:rgb(24,178,178);color:rgb(0,0,0)"></span><span style="font-family:monospace;background-color:rgb(255,255,255);color:rgb(0,0,0)">.</span><br></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><span style="font-family:monospace">-spec test() -> [{atom(), [atom()]}].</span><br><span style="font-family:monospace">% src/test.erl</span><br><span style="font-family:monospace">% Type specification test:test() -> [{atom(),[atom()]}] is a supertype of the success typing: test:test() -> [{'another_test',['d' | 'e' | 'f',...]} | {'one_test',['a' | 'b' | 'c',...]},...]</span><br><span style="font-family:monospace"></span></blockquote><div><br></div><div>Well... both lists are non-empty lists as stated by dialyzer, so I modified the spec, without success:<br></div><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><span style="font-family:monospace">-spec test() -> [{atom(), [atom(), ...]}, ...].<br>%src/test.erl<br>% Type specification test:test() -> [{atom(),[atom(),...]},...] is a supertype of the success typing: test:test() -> [{'another_test',['d' | 'e' | 'f',...]} | {'one_test',['a' | 'b' | 'c',...]},...]<br></span></blockquote><div><br></div><div>Then I tried to explicitly declare it as a proplist, and dialyzer has accepted it:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><span style="font-family:monospace">-spec test() -> proplists:proplist().<br></span><div><span style="font-family:monospace">% OK, no warnings.</span></div></blockquote><div><br></div><div>As it worked, I tried to do the same as proplists module does and created two types, which I used on my new spec. And, surprisingly, dialyzer has complained about it! <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><span style="font-family:monospace">% From <<a href="https://erlang.org/doc/man/proplists.html" target="_blank" style="font-family:monospace">https://erlang.org/doc/man/proplists.html</a>><br></span></div><div><span style="font-family:monospace">-type property() :: atom() | tuple().<br>-type proplist() :: [property()]. <br></span></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><span style="font-family:monospace"><br>-spec test() -> proplist().<br>%src/test.erl <br></span></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><span style="font-family:monospace">% Type specification test:test() -> proplist() is a supertype of the success typing: test:test() -> [{'another_test',['d' | 'e' | 'f',...]} | {'one_test',['a' | 'b' | 'c',...]},...]</span><br></div></blockquote><br><div></div><div></div><div>Therefore, I could not understand why declaring the return as "proplists:proplist" is OK while declaring it as lists, nonempty lists or creating the same types as proplists are not OK. Why is dialyzer complaining about the other specs? Is dialyzer handling proplists in a different way? Could someone help me to understand this behaviour?<br></div><div><br></div><div><br></div><div>Best Regards,</div><div><div><div><div dir="ltr" data-smartmail="gmail_signature">Paulo Zulato<br><br>--<br>«Quis custodiet ipsos custodes?»</div></div></div></div></div>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Sent from Gmail Mobile by Brujo Benavides</div>