[erlang-questions] dialyzer: user-defined types just synonyms?
Kostis Sagonas
kostis@REDACTED
Thu Apr 22 16:18:58 CEST 2010
Dmitry Belyaev wrote:
> I thought type specs are made for external typechecks. Ok. Now I have
> this code:
> -module(test).
>
> -export([start/0]).
>
> -spec start() -> ok.
> start() ->
> AtomBad = get_atom(1),
> AtomGood = get_atom(2),
> check_atom(AtomBad),
> case check_atom(AtomGood) of
> ok -> ok;
> error -> error
> end.
>
> -spec get_atom(any()) -> good | bad.
> get_atom(1) ->
> bad;
> get_atom(_) ->
> good.
>
> -spec check_atom(good | nice) -> ok | error.
> check_atom(Atom) ->
> ok.
>
> It doesn't warn me about check_atom(AtomBad).
It does; see below. You are using an older Erlang/OTP.
Upgrade to R13B04.
Kostis
test.erl:12: The pattern 'error' can never match the type 'ok'
test.erl:21: The specification for test:check_atom/1 states that the
function might also return 'error' but the inferred return is 'ok'
More information about the erlang-questions
mailing list