[erlang-questions] Somebody please correct my -callback understanding

Damian Dobroczyński qoocku@REDACTED
Wed Dec 14 19:11:37 CET 2011


W dniu 14.12.2011 17:58, Damian Dobroczyński pisze:
> Hi list!
> 
> I have a module "a" defining callback "c":
> 
> -module (a).
> -callback c (integer()) -> integer().
> 
> Now, I have callback module "b" implementing invalid (non-comforming the
> a:c/1 spec) callback "c":
> 
> -module (b).
> -behavior (a).
> -export ([c/1]).
> 
> c (A) when is_atom(A) ->
>   A.
> 
> Now, I dialyze both modules:
> 
> $ dialyze -n --src a.erl b.erl
> 
> which outputs:
> 
>   Proceeding with analysis... done in 0m0.64s
> done (passed successfully)
> 
> What I've expected is the dialyzer warning about invalid b:c/1 function
> (something about breaking the contract for c/1). Am I right?
> 
> -- D.

Wow, It's a miracle! I've just found the answer and (what I understand)
a bug. IT IS "-behavior (...)" which is perfectly understood by the
compiler but not by by the dialyzer! Dialyzer expects "-behaviour (...)"
(note the different spelling).

-- D.



More information about the erlang-questions mailing list