<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><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" style="font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class="">Hi all,</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">I've started using Dialyzer and tried to enable as many warnings as possible.</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">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 style="margin-top: 0px; margin-bottom: 0px;" class=""><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 style="margin-top: 0px; margin-bottom: 0px;" class=""><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 style="margin-top: 0px; margin-bottom: 0px;" class=""><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 style="margin-top: 0px; margin-bottom: 0px;" class=""><span class=""><span class=""><span class="">Is there a way to configure Dialyzer the way I want?</span></span></span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class=""><span class=""><span class=""><br class=""></span></span></span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class=""><span class=""><span class="">Here is the demo code:</span></span></span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class=""><span class=""><span class=""><br class=""></span></span></span></div><p style="margin-top: 0px; margin-bottom: 0px;" class=""><span class=""><span class=""><span class=""></span></span></span></p><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, 'Courier New', monospace; font-size: 14px; line-height: 19px;" class=""><div class=""> <span style="color: rgb(96, 139, 78);" class=""># suboptimal implementation, fine for caller</span></div><div class=""> <span style="color: rgb(156, 220, 254);" class="">@spec</span> over_in(x :: integer) :: <span style="color: rgb(86, 156, 214);" class="">nil</span></div><div class=""> <span style="color: rgb(197, 134, 192);" class="">def</span> <span style="color: rgb(220, 220, 170);" class="">over_in</span>(x) <span style="color: rgb(197, 134, 192);" class="">when</span> is_number(x) <span style="color: rgb(197, 134, 192);" class="">do</span></div><div class=""> <span style="color: rgb(86, 156, 214);" class="">nil</span></div><div class=""> <span style="color: rgb(197, 134, 192);" class="">end</span></div><br class=""><div class=""> <span style="color: rgb(96, 139, 78);" class=""># broken caller contract, could return unexpected value</span></div><div class=""> <span style="color: rgb(156, 220, 254);" class="">@spec</span> over_out(x :: number) :: integer</div><div class=""> <span style="color: rgb(197, 134, 192);" class="">def</span> <span style="color: rgb(220, 220, 170);" class="">over_out</span>(x) <span style="color: rgb(197, 134, 192);" class="">when</span> is_number(x) <span style="color: rgb(197, 134, 192);" class="">do</span></div><div class=""> x</div><div class=""> <span style="color: rgb(197, 134, 192);" class="">end</span></div><br class=""><div class=""> <span style="color: rgb(96, 139, 78);" class=""># broken caller contract</span><span style="color: rgb(96, 139, 78);" class="">, rejects input allowed by the spec</span></div><div class=""> <span style="color: rgb(156, 220, 254);" class="">@spec</span> under_in(x :: number) :: <span style="color: rgb(86, 156, 214);" class="">nil</span></div><div class=""> <span style="color: rgb(197, 134, 192);" class="">def</span> <span style="color: rgb(220, 220, 170);" class="">under_in</span>(x) <span style="color: rgb(197, 134, 192);" class="">when</span> is_integer(x) <span style="color: rgb(197, 134, 192);" class="">do</span></div><div class=""> <span style="color: rgb(86, 156, 214);" class="">nil</span></div><div class=""> <span style="color: rgb(197, 134, 192);" class="">end</span></div><br class=""><div class=""> <span style="color: rgb(96, 139, 78);" class=""># current implementation detail, does not concern caller</span></div><div class=""> <span style="color: rgb(156, 220, 254);" class="">@spec</span> under_out(x :: integer) :: number</div><div class=""> <span style="color: rgb(197, 134, 192);" class="">def</span> <span style="color: rgb(220, 220, 170);" class="">under_out</span>(x) <span style="color: rgb(197, 134, 192);" class="">when</span> is_integer(x) <span style="color: rgb(197, 134, 192);" class="">do</span></div><div class=""> x</div><div class=""> <span style="color: rgb(197, 134, 192);" class="">end</span></div></div><br class=""><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div style="margin-top: 0px; margin-bottom: 0px;" class="">and here are the warnings:</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, 'Courier New', monospace; font-size: 14px; line-height: 19px;" class=""><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 style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div id="Signature" class="">Thanks, Dmitry.</div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">erlang-questions mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:erlang-questions@erlang.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class="">erlang-questions@erlang.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""><a href="http://erlang.org/mailman/listinfo/erlang-questions" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class="">http://erlang.org/mailman/listinfo/erlang-questions</a></div></blockquote></div><br class=""></body></html>