我正在开发Elixir,使用Erlang内置的:httpc
函数执行获取请求。
if {:ok, {status, header, body}} = :httpc.request(:get, {img, []}, [], []) do
# ...
end
功能运行良好。然后,在运行混合透析器之后,它将返回错误:
:0:unknown_function
Function :httpc.request/4 does not exist.
________________________________________________________________________________
lib/vutuv/accounts.ex:301:guard_fail
Guard test:
_ :: {:ok, {_, _, _}}
===
false
can never succeed.
________________________________________________________________________________
done (warnings were emitted)
我把这行告诉Dialyzer跳过对功能的检查。
@dialyzer {:nowarn_function, get_gravatar: 2}
但是,错误仍然存在
:0:unknown_function
Function :httpc.request/4 does not exist.
________________________________________________________________________________
done (warnings were emitted)
答案 0 :(得分:0)
此问题已在https://elixirforum.com/t/dialyzer-does-not-know-httpc/21622/3
中解决将:inets
添加到extra_applications
中的mix.exs
之后,一切都成功传递。