[erlang-questions] 12B4 dialyzer problem 3

Anthony Shipman als@REDACTED
Thu Sep 11 12:17:39 CEST 2008


In a simple non-gen_server I have this state:

-record(callState, {
	parent		:: pid(),
	deviceID  	:: integer(),	% the device we are making the call for
       .........
	abort		:: bool(),
	callTag		% reference(), a private signal
	}).

-type state() :: #callState{}.

This start code:

    State = #callState {
	parent        = Parent,
	deviceID      = DeviceID,
        ..............
	abort         = false,
	callTag       = make_ref()
	},
    spawn_link(?MODULE, enter, [State]).

and a loop with this layout:

-spec loopWS(state(), ref()) -> no_return().

loopWS(State, RingTag) ->
    receive
      ...............
    {result, Error} ->
	case State#callState.abort of
	true ->
	    exit(abort);
	false ->
              ........
		    S1 = State#callState{retryCount = Count - 1},
		    loopDelay(S1);
            .........
        end;

    abort ->
	loopWS(State#callState{abort = true}, RingTag);

    ....
    end

where loopDelay makes a tail call back to loopWS.

Dialyzer gives me this error:

caller.erl:234: The call 
caller:loopWS(#callState{abort::'true'},RingTag::ref()) will fail since it 
differs in argument position 1 from the success typing arguments: 
(#callState{retryCount::pos_integer(),abort::'false'},ref())

It seems to have decided already that the abort field can only ever be false 
so my attempt to set it to true is bad.  

The success typing seems to describe the type of S1 which has looped back to 
the type of the first argument to loopWS(). This looks like a bug in the 
reasoning to me.

-- 
Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.



More information about the erlang-questions mailing list