jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.69k stars 141 forks source link

Erlang Typespec issue #391

Closed isaacsanders closed 4 years ago

isaacsanders commented 4 years ago

Environment

 $ asdf current
elixir         1.10.2
erlang         22.2.1
 $ cat mix.lock | grep dia
  "dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},

Current behavior

lib/sftp_client.ex:34:call
The function call will not succeed.

:ssh_sftp.read_file(_pid :: any(), <<_::8, _::size(1)>>)

will never return since the success typing is:
(pid(), string()) :: {:error, atom() | string() | tuple()} | {:ok, binary()}

and the contract is
(channelPid, file) :: {:ok, :Data} | :Error
when channelPid: pid(), file: string(), data: binary(), error: {:error, reason()}

________________________________________________________________________________
done (warnings were emitted)

Expected behavior

This should succeed according to the typespec in erlang documentation.

jeremyjh commented 4 years ago

Dialyzer returning a warning you think is wrong is not going to be a bug in Dialyxir, since we only integrate Dialyzer into Mix. Dialyzer still does the analysis. My advice for this kind of thing is to ask on the elixirforums.com, you will need to supply a code example that can reproduce the problem. 99.99% of the time, the problem is in your code, your typespec or a dependency's typespec.

jeremyjh commented 4 years ago

This is just a warning, and based on the output it does look like the success typing doesn't match the contract. Without seeing your code I couldn't begin to guess.