[erlang-questions] Dialyzer and rpc:pmap

Gustav Simonsson gustav.simonsson@REDACTED
Wed Aug 31 10:45:32 CEST 2011


In Erlang function specifications term() is equivalent with any() which contains the set of all Erlang terms, including the atom 'timeout'.

Looking at the internal rpc function calls from pmap/3, we see that in the end do_yield/2 can return the atom timeout.
However, since do_yield/2 is called as do_yield(Key, infinity) the receive clause in do_yield/2 shouldn't be able to return timeout in the case of calling pmap/3.

Does dialyzer infer that the receive clause in do_yield will wait indefinitely for a matching message in this case, or does it think that a timeout can occur, and therefore include the timeout atom as a possible return value?

Regards,
Gustav Simonsson

----- Original Message -----
From: "Bernie Duggan" <bernie@REDACTED>
To: "Erlang Questions" <erlang-questions@REDACTED>
Sent: Wednesday, August 31, 2011 8:00:26 AM
Subject: [erlang-questions] Dialyzer and rpc:pmap


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: 

---------------------------------------------- 
-module(dialyzer_test). 

-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? 

Cheers, 

Bernard 

_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list