<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>> <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">What you want is provided as a default behaviour.</span></p>
<p><br>
</p>
<p>Hi Alex,</p>
<p><br>
</p>
<p>My observations don't match your statement above:</p>
<p>* Removing -W<span>underspecs switch makes warning in both <i>under_</i> methods disappear</span></p>
<p><span>* Removing -W<span>overspecs switch makes warning in both <i>over_</i> methods disappear</span></span></p>
<p><span><span>* Removing both -W makes all 4 warnings disappear</span></span></p>
<p><span><span><br>
</span></span></p>
<p><span><span>And I'll reply to Jasper's email on usefulness of both <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">underspecs and </span>overspecs.</span></span></p>
<p><span><span><br>
</span></span></p>
<div id="Signature">Thank you, Dmitry.</div>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Alex S. <alex0player@gmail.com><br>
<b>Sent:</b> Monday, March 27, 2017 1:09 AM<br>
<b>To:</b> Dmitry Kakurin<br>
<b>Cc:</b> erlang-questions@erlang.org<br>
<b>Subject:</b> Re: [erlang-questions] Dialyzer underspecs and overspecs options</font>
<div> </div>
</div>
<div>
<div class="">What you want is provided as a default behaviour. Overspecs you shouldn’t really enable for production needs, it’s «debug the Dialyzer» feature.</div>
<div class=""><br class="">
</div>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">24 ìàðòà 2017 ã., â 21:42, Dmitry Kakurin <<a href="mailto:dima_kakurin@hotmail.com" class="">dima_kakurin@hotmail.com</a>> íàïèñàë(à):</div>
<br class="Apple-interchange-newline">
<div class="">
<div id="divtagdefaultwrapper" dir="ltr" class="" style="font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif">
<div class="" style="margin-top:0px; margin-bottom:0px">Hi all,</div>
<div class="" style="margin-top:0px; margin-bottom:0px">I've started using Dialyzer and tried to enable as many warnings as possible.</div>
<div class="" style="margin-top:0px; margin-bottom:0px">Two of them that seem especially useful are <span class=""><i class="">underspecs<span class="Apple-converted-space"> </span></i>and<span class="Apple-converted-space"> </span><i class="">overspecs</i>.</span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class="">But after struggling with warnings produced by them for a while I've realized that what I really need is a subset of each.</span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class="">In the example below (sorry, I'm using Elixir syntax but hope it's still obvious) the 2 warnings I want to enable are <span class=""><b class="">under_in</b><span class="Apple-converted-space"> </span>and <span class=""><b class="">over_out</b>.
 They are the ones that will break callers relying on the spec. While<span class="Apple-converted-space"> </span><i class="">over_in</i><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><i class="">under_out</i><span class="Apple-converted-space"> </span>warnings
 are more of a hints to the function author about current implementation and are much less serious.</span></span></span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class=""><span class=""><span class="">The current Dialyzer options allow me to enable either both over_* warnings or both under_* warnings. But that's not useful.</span></span></span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class=""><span class=""><span class="">Is there a way to configure Dialyzer the way I want?</span></span></span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class=""><span class=""><span class=""><br class="">
</span></span></span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class=""><span class=""><span class="">Here is the demo code:</span></span></span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class=""><span class=""><span class=""><br class="">
</span></span></span></div>
<p class="" style="margin-top:0px; margin-bottom:0px"><span class=""><span class=""><span class=""></span></span></span></p>
<div class="" style="color:rgb(212,212,212); background-color:rgb(30,30,30); font-family:Consolas,'Courier New',monospace; font-size:14px; line-height:19px">
<div class="">  <span class="" style="color:rgb(96,139,78)"># suboptimal implementation, fine for caller</span></div>
<div class="">  <span class="" style="color:rgb(156,220,254)">@spec</span> over_in(x :: integer) :: <span class="" style="color:rgb(86,156,214)">nil</span></div>
<div class="">  <span class="" style="color:rgb(197,134,192)">def</span> <span class="" style="color:rgb(220,220,170)">over_in</span>(x) <span class="" style="color:rgb(197,134,192)">when</span> is_number(x) <span class="" style="color:rgb(197,134,192)">do</span></div>
<div class="">    <span class="" style="color:rgb(86,156,214)">nil</span></div>
<div class="">  <span class="" style="color:rgb(197,134,192)">end</span></div>
<br class="">
<div class="">  <span class="" style="color:rgb(96,139,78)"># broken caller contract, could return unexpected value</span></div>
<div class="">  <span class="" style="color:rgb(156,220,254)">@spec</span> over_out(x :: number) :: integer</div>
<div class="">  <span class="" style="color:rgb(197,134,192)">def</span> <span class="" style="color:rgb(220,220,170)">over_out</span>(x) <span class="" style="color:rgb(197,134,192)">when</span> is_number(x) <span class="" style="color:rgb(197,134,192)">do</span></div>
<div class="">    x</div>
<div class="">  <span class="" style="color:rgb(197,134,192)">end</span></div>
<br class="">
<div class="">  <span class="" style="color:rgb(96,139,78)"># broken caller contract</span><span class="" style="color:rgb(96,139,78)">, rejects input allowed by the spec</span></div>
<div class="">  <span class="" style="color:rgb(156,220,254)">@spec</span> under_in(x :: number) :: <span class="" style="color:rgb(86,156,214)">nil</span></div>
<div class="">  <span class="" style="color:rgb(197,134,192)">def</span> <span class="" style="color:rgb(220,220,170)">under_in</span>(x) <span class="" style="color:rgb(197,134,192)">when</span> is_integer(x) <span class="" style="color:rgb(197,134,192)">do</span></div>
<div class="">    <span class="" style="color:rgb(86,156,214)">nil</span></div>
<div class="">  <span class="" style="color:rgb(197,134,192)">end</span></div>
<br class="">
<div class="">  <span class="" style="color:rgb(96,139,78)"># current implementation detail, does not concern caller</span></div>
<div class="">  <span class="" style="color:rgb(156,220,254)">@spec</span> under_out(x :: integer) :: number</div>
<div class="">  <span class="" style="color:rgb(197,134,192)">def</span> <span class="" style="color:rgb(220,220,170)">under_out</span>(x) <span class="" style="color:rgb(197,134,192)">when</span> is_integer(x) <span class="" style="color:rgb(197,134,192)">do</span></div>
<div class="">    x</div>
<div class="">  <span class="" style="color:rgb(197,134,192)">end</span></div>
</div>
<br class="">
<p class="" style="margin-top:0px; margin-bottom:0px"></p>
<div class="" style="margin-top:0px; margin-bottom:0px">and here are the warnings:</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<p class="" style="margin-top:0px; margin-bottom:0px"></p>
<div class="" style="color:rgb(212,212,212); background-color:rgb(30,30,30); font-family:Consolas,'Courier New',monospace; font-size:14px; line-height:19px">
<div class="">demo.ex:4: Type specification</div>
<div class="">'Elixir.Virt':over_in(x::integer()) -> 'nil' is a subtype of the success typing: </div>
<div class="">'Elixir.Virt':over_in(number()) -> 'nil'</div>
<div class=""><br class="">
</div>
<div class="">demo.ex:9: Type specification</div>
<div class="">'Elixir.Virt':over_out(x::number()) -> integer() is a subtype of the success typing:</div>
<div class="">'Elixir.Virt':over_out(number()) -> number()</div>
<div class=""><br class="">
</div>
<div class="">demo.ex:14: Type specification</div>
<div class="">'Elixir.Virt':under_in(x::number()) -> 'nil' is a supertype of the success typing:</div>
<div class="">'Elixir.Virt':under_in(integer()) -> 'nil'</div>
<div class=""><br class="">
</div>
<div class="">demo.ex:19: The specification for 'Elixir.Virt':under_out/1 states that the function might also return</div>
<div class="">float() but the inferred return is</div>
<div class="">integer()</div>
<div class=""></div>
</div>
<br class="">
<p class="" style="margin-top:0px; margin-bottom:0px"></p>
<div id="Signature" class="">Thanks, Dmitry.</div>
</div>
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; float:none; display:inline!important">_______________________________________________</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; float:none; display:inline!important">erlang-questions
 mailing list</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">
<a href="mailto:erlang-questions@erlang.org" class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">erlang-questions@erlang.org</a><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">
<a href="http://erlang.org/mailman/listinfo/erlang-questions" class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">http://erlang.org/mailman/listinfo/erlang-questions</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</body>
</html>