[erlang-questions] Dialyzer cannot catch gen_server callback return type error
Maxim Treskin
zerthurd@REDACTED
Fri Jul 6 13:36:55 CEST 2012
On 6 July 2012 17:35, Stavros Aronis <aronisstav@REDACTED> wrote:
> Hi again,
>
> The signature (or "success typing" in Dialyzer's terminology) is
> `my_module:handle_cast(term(),term()) -> {'noreply',term()}` because the
> second clause:
>
> handle_cast(_Msg, State) ->
> {noreply, State}.
>
> will accept any terms as _Msg and State and return {noreply, State} in
> which State again is any term. In Dialyzer's type system, this {noreply,
> term()} return value will 'absorb' the definitely incorrect {noreply,
> {bugotak}} as {bugotak} is also a term(). From that point on, Dialyzer can
> assume that term() might also be #state{} and emit no warnings. This
> happens because Dialyzer checks the whole range of return values at once
> and not each particular clause. If all the return values were definitely
> different than #state{}, then and only then would Dialyzer warn you.
>
>
Thanks for the clarification, Stavros! Now I understand how Dialyzer checks
types of function clauses.
> Again, trying to check each particular return value against a given spec
> might be an interesting extension and we will consider it in the future.
>
>
I hope so. It would be a significant level up!
> Stavros
>
> On Fri, Jul 6, 2012 at 11:39 AM, Maxim Treskin <zerthurd@REDACTED> wrote:
>
>> I just really not understand. Function handle_cast returns, and returns
>> incorrect type according to -spec signature, right?
>> Why Dialyzer lose this information? It is sort of missbehaviour i think.
>>
>> --
>> Max Treskin
>>
>
>
--
Max Treskin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120706/57154eff/attachment.htm>
More information about the erlang-questions
mailing list