[erlang-questions] Dialyzer and List Type

PhayTsukiming moonsolo@REDACTED
Tue Apr 19 08:50:33 CEST 2016


Hi list, I am new to erlang and dialyzer. I have encounter a problem when I
tried to fiddle with type specifications.

Say, I have two functions:

-module(t).
-export([foo/1, bar/1]).

-spec foo([integer()])->[integer()].
foo(Arg)->
    [I+1||I<-Arg].

-spec bar(atom())->[integer()].
bar(_Arg)->
    foo(_Arg).

Then apply dialyzer to this module and dialyzer warns:

t.erl:8: Invalid type specification for function t:bar/1. The success
typing is ([integer()]) -> [integer()]

But if I change the specification of bar to:

-spec bar([atom()])->[integer()].

dialyzer will show no warnings. My intention is to make sure the argument
of bar is the same type of list as the argument of foo.

Is this normal? Do I miss or misunderstand something about success typing
or dialyzer?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160419/d1fe43d5/attachment.htm>


More information about the erlang-questions mailing list