picky dialyzer

Ulf Wiger ulf.wiger@REDACTED
Thu Jan 13 11:13:13 CET 2011


This has me confused:

Compiled src/jobs_server.erl
==> jobs (analyze)
jobs_server.erl:1251: The pattern {'queue', _, _, {'producer', _}, _, _, _, _, _, _, _, _, _, _} can never match the type #queue{mod::atom(),type::'fifo' | #action{a::'approve' | 'reject'} | #passive{type::'fifo'},group::atom(),...}

The line in question is 

q_is_empty(#queue{type = #producer{}}) -> false;


The #queue{} record definition is:

-record(producer, {f :: mfa() | function()}).
-record(passive , {type = fifo   :: fifo}).
-record(action  , {a = approve   :: approve | reject}).

-record(queue, {name                 :: any(),
		mod                  :: atom(),
		type = fifo          :: fifo | #producer{} | #passive{} | #action{},
		group                :: atom(),
                …}

Why does dialyzer think that #producer{} is not a valid member of
the type def for the 'type' attribute?

The funny thing is that if I rename the #producer{} record to e.g. 
#prod{} or #produce{}, dialyzer picks it up (but generates a bunch of 
other problems, partly because the change wasn't done consistently throughout).

This (or practically the same warning) can be reproduced by pulling the 
latest version of http://github.com/esl/jobs and running ./rebar analyze

BR,
Ulf W

Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com





More information about the erlang-questions mailing list