[erlang-questions] Dialyzer and rpc:pmap

Bernie Duggan <>
Wed Aug 31 08:00:26 CEST 2011

Hi all (Hi dialyzer people especially :))

I have been having a heated debate with dialyzer over the return value of
rpc:pmap/3.  The following code demonstrates the issue:


-export([run/0, f/1]).

run() ->
    A = [{a, a}, {b, b}],
    B = [X || {a, X} <- A],

    C = rpc:pmap({?MODULE, f}, [], A),
    D = [X || {a, X} <- C],
    {B, D}.

f(X) -> X.

Basically I have a list, A, and an rpc:pmap call to the identity function
with A as the list - this quite correctly returns A (stored in C). Next, I
run a filter list comprehension over A and C to grab just the tuples with
'a' as their first element. The code all works fine (returning {[a], [a]})
but dialyzer complains:

dialyzer_test.erl:10: The pattern [{'a', X} | _] can never match the type
['timeout' | {'value',_}]

Line 10 is the "D =..." line. It looks like the return value of rpc:pmap is
being inferred incorrectly, but the -spec for it in rpc.erl gives the return
type as [term()] which is what I'd expect.

Any hints? Something obvious I've missed?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110831/4aaddba2/attachment.html>

More information about the erlang-questions mailing list