why can't dialyzer see that my spec is a lie?

Matthias Lang matthias@REDACTED
Thu Feb 10 12:00:48 CET 2011


Hi,

Running the example below through dialyzer R14B01:

  143> dialyzer:run([{from, src_code}, {files, ["minimal.erl"]}]). 
  []

I was hoping Dialyzer would complain that my spec (line 18) is a lie.

Cut down, but compilable, code below. Changing "almost anything" results
in a good warning, e.g. if I comment out the recursive step (line 13):

  145> dialyzer:run([{from, src_code}, {files, ["minimal.erl"]}]).
  [{warn_contract_types,{"/tmp/minimal.erl",17},
                      {extra_range,[minimal,parse_and_execute,1,"'quit'",
                                    "{_,_}"]}}]

What's going on? I'm stumped.

Matt

----------------------------------------------------------------------
-module(minimal).
-export([start/0]).

-record(state, {commands}).

start() ->
    Fun = fun() -> {quit, "string"} end,
    server_loop(#state{commands=Fun}).

server_loop(State) ->
    try
	{New_state, _} = parse_and_execute(State),
	server_loop(New_state)
    catch
	_:_ -> ok
    end.

-spec parse_and_execute(any()) -> {#state{}, string()} | 'quit'.

parse_and_execute(State) ->
    Fun = State#state.commands,
    Fun().




More information about the erlang-questions mailing list