[erlang-questions] 12B4 dialyzer problem 2
Thu Sep 11 12:41:30 CEST 2008
Anthony Shipman wrote:
> I have a gen_server with a state record specified as:
> .... SNIP ...
> I get this error from dialyzer:
> stream_reman.erl:576: The call streamIface:specialToDevice('undefined' |
> pid(),'undefined' | integer(),'streamClose')
> breaks the contract (serverRef(),integer(),specialCtrl()) -> 'ok'
> It appears that dialyzer can't prove that the parent and strmID fields can
> never be undefined. This isn't surprising.
Yes, this is not surprising and indeed Dialyzer does not have any
analysis that allows it to prove that record fields cannot have some
value. But this is NOT the problem here.
The error you get is:
- either because serverRef() does not include pid() in its definition
- or because specialCtrl() does not include the atom 'streamClose'
It has nothing to do with 'undefined'. I suggest you take a closer look
at these types.
However, the following is very interesting:
> But I expected that dialyzer would accept the declaration
> parent :: pid(),
> to tell it that the field is never undefined.
Type declarations in record fields have an implicit 'undefined' in them,
unless there is an explicit initialization of the field, as e.g. in
parent = self() :: pid()
More information about the erlang-questions