user483036
user483036

Reputation:

"dialyzer: Analysis failed with error.." (dialyzer bug? or wrong use of map-type?)

Working on a very simple application in my progress of learning elixir, I ran into a minor roadblock when checking the types with dialyzer. Running dialyzer on my code results in an Analysis failed error... So far dialyzer has only given me warnings and not errors when I violate the type spec's, so I have no clue what the error is about.

Trying to narrow down the problem, I made an ultra simple function which performs the offending return value.

  @spec blabla(integer) :: %{atom => any}
  def blabla(1) do
    %{:error => 'wrong input (US-state)'}
  end
  def blabla(2) do
    %{ location: 'New York City, Central Park, NY', temp_c: '23.3',
       visibility_mi: '10.00', weather: 'A Few Clouds', wind_dir: 'North',
       wind_kt: '0' }
  end

When running dialyzer on this I get following error

  Proceeding with analysis...
=ERROR REPORT==== 14-Jul-2015::17:26:55 ===
Error in process <0.31.0> with exit value: {function_clause,[{erl_types,t_form_to_string,[{type,12,map_field_assoc,{type,12,atom,[]},{type,12,any,[]}}],[{file,"erl_types.erl"},{line,4546}]},{erl_types,t_form_to_string_list,2,[{file,"erl_types.erl"},{line,4637}]},{erl_types,t_form_to_string... 


dialyzer: Analysis failed with error:
{function_clause,[{erl_types,t_form_to_string,
                             [{type,12,map_field_assoc,
                                    {type,12,atom,[]},
                                    {type,12,any,[]}}],
                             [{file,"erl_types.erl"},{line,4546}]},
                  {erl_types,t_form_to_string_list,2,
                             [{file,"erl_types.erl"},{line,4637}]},
                  {erl_types,t_form_to_string,1,
                             [{file,"erl_types.erl"},{line,4634}]},
                  {erl_types,t_form_to_string,1,
                             [{file,"erl_types.erl"},{line,4590}]},
                  {dialyzer_contracts,contract_to_string_1,1,
                                      [{file,"dialyzer_contracts.erl"},
                                       {line,107}]},
                  {dialyzer_contracts,extra_contract_warning,6,
                                      [{file,"dialyzer_contracts.erl"},
                                       {line,712}]},
                  {dialyzer_contracts,picky_contract_check,7,
                                      [{file,"dialyzer_contracts.erl"},
                                       {line,686}]},
                  {dialyzer_contracts,get_invalid_contract_warnings_funs,5,
                                      [{file,"dialyzer_contracts.erl"},
                                       {line,654}]}]}

Am I defining the map-type in a wrong way? or is this some bug in dialyzer?

Upvotes: 2

Views: 405

Answers (1)

There is nothing wrong with your code or the typespec. Looks like a dialyzer bug, you can try updating to the latest version of Erlang.

Upvotes: 2

Related Questions