"dialyzer: Analysis failed with error.."(透析器错误?或错误使用地图类型?)
"dialyzer: Analysis failed with error.." (dialyzer bug? or wrong use of map-type?)
在我学习 elixir 的过程中开发了一个非常简单的应用程序,我 运行 在使用透析器检查类型时遇到了一个小障碍。 运行 dialyzer 在我的代码中导致 Analysis failed
错误...到目前为止 dialyzer 只给我 warnings 而不是 errors 当我违反类型规范时,所以我不知道错误是什么。
为了缩小问题范围,我做了一个超简单的函数来执行有问题的 return 值。
@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
当 运行 dialyzer 在此时,我收到以下错误
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}]}]}
我是否以错误的方式定义了地图类型?或者这是透析器中的一些错误?
您的代码或类型规范没有任何问题。好像是透析器的bug,你可以尝试更新到最新版本的Erlang。
在我学习 elixir 的过程中开发了一个非常简单的应用程序,我 运行 在使用透析器检查类型时遇到了一个小障碍。 运行 dialyzer 在我的代码中导致 Analysis failed
错误...到目前为止 dialyzer 只给我 warnings 而不是 errors 当我违反类型规范时,所以我不知道错误是什么。
为了缩小问题范围,我做了一个超简单的函数来执行有问题的 return 值。
@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
当 运行 dialyzer 在此时,我收到以下错误
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}]}]}
我是否以错误的方式定义了地图类型?或者这是透析器中的一些错误?
您的代码或类型规范没有任何问题。好像是透析器的bug,你可以尝试更新到最新版本的Erlang。