[erlang-questions] -callback directives with Dialyzer

Matthew Fitzpatrick matthew.fitzpatrick6012@REDACTED
Tue Sep 15 19:39:00 CEST 2015

Hey All,

This was done with Erlang R15B02.

The example code and problem can also be seen here:

Based on everything I've been reading and looking at, it seemed like if I
have a behavior like this...

% dude.erl
-callback hey_dude(Say :: string()) -> Res :: string().

And I then implement it...

% no_spec_dude.erl
hey_dude(Say) ->
  lists:flatten(io_lib:format("Hey Dude, ~p", [Say])).

And finally, I try to use it...

% runner.erl
-spec run() -> ok.
run() ->
  io:format("~p", [no_spec_dude:hey_dude(42)]).

If i run dialyzer with these 3 files, It should complain about a contract
violation right? Except I'm running into the problem of that its not. I
created a sample repo with the output of dialyzer here:
https://github.com/Ceryni/cuddly-octo-adventure. If I explicitly define
`-spec` then it works as expected and barks at me for using an integer
instead of a string, but I thought dialyzer would use the -callback? Any
thoughts on what I'm doing wrong here? Maybe using dialyzer incorrectly? My
Erlang SDK is too old? Just trying to figure out what's going on.

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150915/7b8a0c3f/attachment.htm>

More information about the erlang-questions mailing list